Helix Installation   Getting Started   Reference Documentation   Global Functions   Quick Start
ModulesClassesFunctions
 

Class Reference

class mail extends obj

Helix obj mail
Hide Inherited MembersHelix Core
Description
No description.
 
Constants
No constants.
 
Properties
protected_attachments[ mail ]
protected_bcc[ mail ]
private_boundary[ mail ]
protected_cc[ mail ]
protected_dirty[ obj ]
protected_from[ mail ]
protected_headers[ mail ]
protected_html[ mail ]
protected_importance[ mail ]
protected_message[ mail ]
private_phpmailer[ mail ]
protected_priority[ mail ]
publicproperty_objects_array[ obj ]
protected_subject[ mail ]
protected_to[ mail ]
 
Methods
privateaddress ( address )[ mail ]
Parameters
requiredaddress
Code
247  private function address($__address)
248  {
249      if (stristr($__address,"<"))
250      {
251          return trim(substr($__address,strpos($__address,"<")+1,strpos($__address,">")-strpos($__address,"<")-1));
252      }
253      else
254      {
255          return $__address;
256      }
257  }
publicattach ( path , disposition ["attachment"] , name )[ mail ]
Parameters
requiredpath
optionaldisposition ["attachment"]
optionalname
Code
050  public function attach($__path, $__disposition="attachment", $__name=null)
051  {
052      $key = md5($__path);
053      $name = is_null($__name) ? basename($__path) : $__name;
054      $this->_attachments[$key]["content"] = chunk_split(base64_encode(file_get_contents($__path)));
055      $this->_attachments[$key]["Content-Type"] = mime($name) . "; name=\"" . $name . ";\"";
056      $this->_attachments[$key]["Content-Disposition"] = $__disposition;
057      $this->_attachments[$key]["Content-Transfer-Encoding"] = "base64";
058 
059      $this->_phpmailer->AddAttachment($__path,$name,"base64",mime($name));
060  }
public__construct ( to , subject , message , from , cc , bcc )[ mail ]
Parameters
optionalto
optionalsubject
optionalmessage
optionalfrom
optionalcc
optionalbcc
Code
020  public function __construct($__to=null, $__subject=null, $__message=null, $__from=null, $__cc=null, $__bcc=null)
021  {
022      $this->_phpmailer = new PHPMailer();
023      $this->_phpmailer->Subject    = $__subject;
024      $this->_phpmailer->Body = nl2br($__message);
025      $this->_phpmailer->AltBody = $__message;
026      if (!is_null(estn($__from)))
027      {
028          $this->_phpmailer->From       = $this->address($__from);
029          $this->_phpmailer->FromName   = $this->name($__from);
030          $this->_phpmailer->AddReplyTo($this->_phpmailer->From,$this->_phpmailer->FromName);
031      }
032 
033      $this->_to = array();
034      $this->_cc = array();
035      $this->_bcc = array();
036      $this->to = $__to;
037      $this->cc = $__cc;
038      $this->bcc = $__bcc;
039      $this->_from = $__from;
040      $this->_message = $__message;
041      $this->_subject = $__subject;
042      $this->_attachments = array();
043      $this->_boundary = sha1(uniqid(timestamp(),true));
044      $this->_headers = array();
045      $this->_html = false;
046      $this->_importance = "normal";
047      $this->_priority = "normal";
048  }
public__get ( p )[ obj ]
Parameters
requiredp
Code
007  public function __get($p)
008  {
009      $methods = get_class_methods($this);
010      $properties = get_object_vars($this);
011      if (in_array("get_$p",$methods))
012      {
013          return $this->{"get_$p"}();
014      }
015      else if (array_key_exists("_$p",$properties))
016      {
017          return $this->{"_$p"};
018      }
019      else if (in_array("get_" . substr($p,strpos($p,"_")+1), $methods))
020      {
021          return $this->{"get_" . substr($p,strpos($p,"_")+1)}(substr($p,0,strpos($p,"_")));
022      }
023      else
024      {
025          trigger_error("This object [" . get_class($this) . ":$this->id] has no private property '_$p' for the requested public property '$p'",E_USER_WARNING);
026          return null;
027      }
028  }
publicget_array ( )[ obj ]
Parameters
No parameters for this method
Code
096  public function get_array()
097  {
098      return get_object_vars($this);
099  }
publicget_bcc ( )[ mail ]
Parameters
No parameters for this method
Code
229  public function get_bcc()
230  {
231      $bcc = implode(",",$this->_bcc);
232      return $bcc;
233  }
publicget_cc ( )[ mail ]
Parameters
No parameters for this method
Code
223  public function get_cc()
224  {
225      $cc = implode(",",$this->_cc);
226      return $cc;
227  }
publicget_classname ( )[ obj ]
Parameters
No parameters for this method
Code
086  public function get_classname()
087  {
088      return get_class($this);
089  }
publicget_content_type ( )[ mail ]
Parameters
No parameters for this method
Code
205  public function get_content_type()
206  {
207      if (count($this->_attachments) > 0)
208      {
209          return ($this->_html ? "multipart/alternative" : "multipart/mixed") . "; boundary=\"$this->_boundary\";";
210      }
211      else
212      {
213          return ($this->_html ? "text/html" : "text/plain") . "; charset=\"ISO-8859-1\"";
214      }
215  }
publicget_dirty ( )[ obj ]
Parameters
No parameters for this method
Code
063  public function get_dirty()
064  {
065      if ($this->id === 0)
066      {
067          $this->_dirty = true;
068      }
069      else
070      {
071          foreach (get_object_vars($this) as $k=>$v)
072          {
073              if ($this->_dirty)
074              {
075                  break;
076              }
077              if (preg_match('/_dirty$/',$k))
078              {
079                  $this->_dirty = $this->_dirty || $v;
080              }
081          }
082      }
083      return $this->_dirty;
084  }
publicget_headers ( )[ mail ]
Parameters
No parameters for this method
Code
180  public function get_headers()
181  {
182      $this->_headers["MIME-Version"] = "1.0";
183      $this->_headers["Content-Type"] = $this->content_type;
184      $this->_headers["Content-Transfer-Encoding"] = "7bit";
185      $this->_headers["Importance"] = $this->_importance;
186      $this->_headers["Priority"] = $this->_priority;
187 
188      $headers = array();
189      $headers[] = "From: $this->_from";
190      if (is_array($this->_cc) && count($this->_cc) > 0)
191      {
192          $headers[] = "Cc: $this->cc";
193      }
194      if (is_array($this->_bcc) && count($this->_bcc) > 0)
195      {
196          $headers[] = "Bcc: $this->bcc";
197      }
198      foreach ($this->_headers as $k=>$v)
199      {
200          $headers[] = $k . ": " . $v;
201      }
202      return $headers;
203  }
publicget_json ( )[ obj ]
Parameters
No parameters for this method
Code
101  public function get_json()
102  {
103      $class = new ReflectionClass($this->classname);
104      $methods = $class->getMethods();
105      usort($methods,"sort_reflection_objects");
106      $accessors = array();
107      foreach ($methods as $index=>$method)
108      {
109          $declarer = $method->getDeclaringClass()->name;
110          if (preg_match('/^(get|set|)_(.+)$/',$method->name,$matches))
111          {
112              $accessor = $matches[2];
113              $getset = $matches[1];
114              eval("\$accessors[\$accessor] = \$this->".$accessor.";");
115          }
116      }
117      //return json_encode($this->get_array());
118      return json_encode($accessors);
119  }
publicget_properties ( )[ obj ]
Parameters
No parameters for this method
Code
121  public function get_properties()
122  {
123      return array_keys($this->array);
124  }
protectedget_string ( )[ obj ]
Parameters
No parameters for this method
Code
091  protected function get_string()
092  {
093      return method_exists($this,"__toString") ? $this->__toString() : null;
094  }
publicget_to ( )[ mail ]
Parameters
No parameters for this method
Code
217  public function get_to()
218  {
219      $to = implode(",",$this->_to);
220      return $to;
221  }
privatename ( address )[ mail ]
Parameters
requiredaddress
Code
235  private function name($__address)
236  {
237      if (stristr($__address,"<"))
238      {
239          return trim(substr($__address,0,strpos($__address,"<")));
240      }
241      else
242      {
243          return null;
244      }
245  }
publicsend ( )[ mail ]
Parameters
No parameters for this method
Code
062  public function send()
063  {
064      $message = $this->_message;
065      if (count($this->_attachments) > 0)
066      {
067          $message = "";
068 
069          if (!is_null($this->_message))
070          {
071              $message .= "--" . $this->_boundary . "\r\n";
072              $message .= "Content-Type: " . (($this->_html ? "text/html" : "text/plain") . "; charset=\"iso-8859-1\"") . "\r\n";
073              $message .= "Content-Transfer-Encoding: 7bit" . "\r\n" . "\r\n";
074              $message .= $this->_message . "\r\n" . "\r\n";
075          }
076 
077          foreach ($this->_attachments as $attachment)
078          {
079              $message .= "--" . $this->_boundary . "\r\n";
080              $message .= "Content-Type: " . $attachment["Content-Type"] . "\r\n";
081              $message .= "Content-Disposition: " . $attachment["Content-Disposition"] . "\r\n";
082              $message .= "Content-Transfer-Encoding: " . $attachment["Content-Transfer-Encoding"] . "\r\n" . "\r\n";
083              $message .= $attachment["content"];
084              $message .= "\r\n" . "\r\n";
085          }
086 
087          $message .= "--" . $this->_boundary . "--" . "\r\n";
088      }
089      $additional_headers = implode("\n",$this->headers);
090 
091      if (defined("USEGMAIL") && is_true(USEGMAIL))
092      {
093          $this->_phpmailer->IsSMTP();
094          $this->_phpmailer->SMTPAuth   = true;                  // enable SMTP authentication
095          $this->_phpmailer->SMTPSecure = "ssl";                 // sets the prefix to the servier
096          $this->_phpmailer->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
097          $this->_phpmailer->Port       = 465;                   // set the SMTP port
098          $this->_phpmailer->Username   = GMAILUSERNAME// GMAIL username
099          $this->_phpmailer->Password   = GMAILPASSWORD;            // GMAIL password
100          $this->_phpmailer->Send();
101      }
102      else
103      {
104          return mail($this->to, $this->_subject, $message, $additional_headers);
105      }
106  }
public__set ( p , v )[ obj ]
Parameters
requiredp
requiredv
Code
030  public function __set($p,$v)
031  {
032      $methods = get_class_methods($this);
033      $properties = get_object_vars($this);
034      if (in_array("set_$p",$methods))
035      {
036          $this->{"set_$p"}($v);
037      }
038      else if (array_key_exists("_$p",$properties))
039      {
040          if (!preg_match('/_dirty$/',$p) && property_exists($this,"_{$p}_dirty"))
041          {
042              if (is_object($this->{"_$p"}))
043              {
044                  $this->{"_$p"}->dirty = true;
045              }
046              else
047              {
048                  $this->{"_{$p}_dirty"} = $this->{$p}==$v ? false : true;
049              }
050          }
051          $this->{"_$p"} = $v;
052      }
053      else if (in_array("set_" . substr($p,strpos($p,"_")+1), $methods))
054      {
055          $this->{"set_" . substr($p,strpos($p,"_")+1)}($v,substr($p,0,strpos($p,"_")));
056      }
057      else
058      {
059          trigger_error("This object [" . get_class($this) . ":$this->id] has no private property '_$p' for the requested public property '$p'",E_USER_WARNING);
060      }
061  }
publicset_bcc ( emails )[ mail ]
Parameters
requiredemails
Code
156  public function set_bcc($__emails)
157  {
158      if (is_array($__emails))
159      {
160          $this->_bcc = array_unique(array_merge($this->_bcc, $__emails));
161          foreach($this->_bcc as $bcc)
162          {
163              $this->_phpmailer->AddBCC($this->address($bcc),$this->name($bcc));
164          }
165      }
166      else
167      {
168          $email_list = preg_split("/[;,]/i",$__emails);
169          foreach ($email_list as $email)
170          {
171              if (strlen($email) > 0)
172              {
173                  $this->_bcc[] = $email;
174                  $this->_phpmailer->AddBCC($this->address($email),$this->name($email));
175              }
176          }
177      }
178  }
publicset_cc ( emails )[ mail ]
Parameters
requiredemails
Code
132  public function set_cc($__emails)
133  {
134      if (is_array($__emails))
135      {
136          $this->_cc = array_unique(array_merge($this->_cc, $__emails));
137          foreach($this->_cc as $cc)
138          {
139              $this->_phpmailer->AddCC($this->address($cc),$this->name($cc));
140          }
141      }
142      else
143      {
144          $email_list = preg_split("/[;,]/i",$__emails);
145          foreach ($email_list as $email)
146          {
147              if (strlen($email) > 0)
148              {
149                  $this->_cc[] = $email;
150                  $this->_phpmailer->AddCC($this->address($email),$this->name($email));
151              }
152          }
153      }
154  }
publicset_from ( v )[ mail ]
Parameters
requiredv
Code
259  public function set_from($__v)
260  {
261      $this->_from = $__v;
262      $this->_phpmailer->From       = $this->address($__v);
263      $this->_phpmailer->FromName   = $this->name($__v);
264      $this->_phpmailer->AddReplyTo($this->address($__v),$this->name($__v));
265  }
publicset_message ( v )[ mail ]
Parameters
requiredv
Code
273  public function set_message($__v)
274  {
275      $this->_message = $__v;
276      $this->_phpmailer->Body = nl2br($__v);
277      $this->_phpmailer->AltBody = $__v;
278  }
publicset_subject ( v )[ mail ]
Parameters
requiredv
Code
267  public function set_subject($__v)
268  {
269      $this->_subject = $__v;
270      $this->_phpmailer->Subject = $__v;
271  }
publicset_to ( emails )[ mail ]
Parameters
requiredemails
Code
108  public function set_to($__emails)
109  {
110      if (is_array($__emails))
111      {
112          $this->_to = array_unique(array_merge($this->_to, $__emails));
113          foreach($this->_to as $to)
114          {
115              $this->_phpmailer->AddAddress($this->address($to),$this->name($to));
116          }
117      }
118      else
119      {
120          $email_list = preg_split("/[;,]/i",$__emails);
121          foreach ($email_list as $email)
122          {
123              if (strlen($email) > 0)
124              {
125                  $this->_to[] = $email;
126                  $this->_phpmailer->AddAddress($this->address($email),$this->name($email));
127              }
128          }
129      }
130  }
 
Accessors
publicarray[ obj ]
Code
096  public function get_array()
097  {
098      return get_object_vars($this);
099  }
publicbcc[ mail ]
Code
229  public function get_bcc()
230  {
231      $bcc = implode(",",$this->_bcc);
232      return $bcc;
233  }
Code
156  public function set_bcc($__emails)
157  {
158      if (is_array($__emails))
159      {
160          $this->_bcc = array_unique(array_merge($this->_bcc, $__emails));
161          foreach($this->_bcc as $bcc)
162          {
163              $this->_phpmailer->AddBCC($this->address($bcc),$this->name($bcc));
164          }
165      }
166      else
167      {
168          $email_list = preg_split("/[;,]/i",$__emails);
169          foreach ($email_list as $email)
170          {
171              if (strlen($email) > 0)
172              {
173                  $this->_bcc[] = $email;
174                  $this->_phpmailer->AddBCC($this->address($email),$this->name($email));
175              }
176          }
177      }
178  }
publiccc[ mail ]
Code
223  public function get_cc()
224  {
225      $cc = implode(",",$this->_cc);
226      return $cc;
227  }
Code
132  public function set_cc($__emails)
133  {
134      if (is_array($__emails))
135      {
136          $this->_cc = array_unique(array_merge($this->_cc, $__emails));
137          foreach($this->_cc as $cc)
138          {
139              $this->_phpmailer->AddCC($this->address($cc),$this->name($cc));
140          }
141      }
142      else
143      {
144          $email_list = preg_split("/[;,]/i",$__emails);
145          foreach ($email_list as $email)
146          {
147              if (strlen($email) > 0)
148              {
149                  $this->_cc[] = $email;
150                  $this->_phpmailer->AddCC($this->address($email),$this->name($email));
151              }
152          }
153      }
154  }
publicclassname[ obj ]
Code
086  public function get_classname()
087  {
088      return get_class($this);
089  }
publiccontent_type[ mail ]
Code
205  public function get_content_type()
206  {
207      if (count($this->_attachments) > 0)
208      {
209          return ($this->_html ? "multipart/alternative" : "multipart/mixed") . "; boundary=\"$this->_boundary\";";
210      }
211      else
212      {
213          return ($this->_html ? "text/html" : "text/plain") . "; charset=\"ISO-8859-1\"";
214      }
215  }
publicdirty[ obj ]
Code
063  public function get_dirty()
064  {
065      if ($this->id === 0)
066      {
067          $this->_dirty = true;
068      }
069      else
070      {
071          foreach (get_object_vars($this) as $k=>$v)
072          {
073              if ($this->_dirty)
074              {
075                  break;
076              }
077              if (preg_match('/_dirty$/',$k))
078              {
079                  $this->_dirty = $this->_dirty || $v;
080              }
081          }
082      }
083      return $this->_dirty;
084  }
publicfrom[ mail ]
Code
259  public function set_from($__v)
260  {
261      $this->_from = $__v;
262      $this->_phpmailer->From       = $this->address($__v);
263      $this->_phpmailer->FromName   = $this->name($__v);
264      $this->_phpmailer->AddReplyTo($this->address($__v),$this->name($__v));
265  }
publicheaders[ mail ]
Code
180  public function get_headers()
181  {
182      $this->_headers["MIME-Version"] = "1.0";
183      $this->_headers["Content-Type"] = $this->content_type;
184      $this->_headers["Content-Transfer-Encoding"] = "7bit";
185      $this->_headers["Importance"] = $this->_importance;
186      $this->_headers["Priority"] = $this->_priority;
187 
188      $headers = array();
189      $headers[] = "From: $this->_from";
190      if (is_array($this->_cc) && count($this->_cc) > 0)
191      {
192          $headers[] = "Cc: $this->cc";
193      }
194      if (is_array($this->_bcc) && count($this->_bcc) > 0)
195      {
196          $headers[] = "Bcc: $this->bcc";
197      }
198      foreach ($this->_headers as $k=>$v)
199      {
200          $headers[] = $k . ": " . $v;
201      }
202      return $headers;
203  }
publicjson[ obj ]
Code
101  public function get_json()
102  {
103      $class = new ReflectionClass($this->classname);
104      $methods = $class->getMethods();
105      usort($methods,"sort_reflection_objects");
106      $accessors = array();
107      foreach ($methods as $index=>$method)
108      {
109          $declarer = $method->getDeclaringClass()->name;
110          if (preg_match('/^(get|set|)_(.+)$/',$method->name,$matches))
111          {
112              $accessor = $matches[2];
113              $getset = $matches[1];
114              eval("\$accessors[\$accessor] = \$this->".$accessor.";");
115          }
116      }
117      //return json_encode($this->get_array());
118      return json_encode($accessors);
119  }
publicmessage[ mail ]
Code
273  public function set_message($__v)
274  {
275      $this->_message = $__v;
276      $this->_phpmailer->Body = nl2br($__v);
277      $this->_phpmailer->AltBody = $__v;
278  }
publicproperties[ obj ]
Code
121  public function get_properties()
122  {
123      return array_keys($this->array);
124  }
publicstring[ obj ]
Code
091  protected function get_string()
092  {
093      return method_exists($this,"__toString") ? $this->__toString() : null;
094  }
publicsubject[ mail ]
Code
267  public function set_subject($__v)
268  {
269      $this->_subject = $__v;
270      $this->_phpmailer->Subject = $__v;
271  }
publicto[ mail ]
Code
217  public function get_to()
218  {
219      $to = implode(",",$this->_to);
220      return $to;
221  }
Code
108  public function set_to($__emails)
109  {
110      if (is_array($__emails))
111      {
112          $this->_to = array_unique(array_merge($this->_to, $__emails));
113          foreach($this->_to as $to)
114          {
115              $this->_phpmailer->AddAddress($this->address($to),$this->name($to));
116          }
117      }
118      else
119      {
120          $email_list = preg_split("/[;,]/i",$__emails);
121          foreach ($email_list as $email)
122          {
123              if (strlen($email) > 0)
124              {
125                  $this->_to[] = $email;
126                  $this->_phpmailer->AddAddress($this->address($email),$this->name($email));
127              }
128          }
129      }
130  }
Get Helix PHP Framework at SourceForge.net. Fast, secure and Free Open Source software downloads