ILIAS  release_4-4 Revision
Mail_mail Class Reference
+ Inheritance diagram for Mail_mail:
+ Collaboration diagram for Mail_mail:

Public Member Functions

 Mail_mail ($params=null)
 Constructor. More...
 
 send ($recipients, $headers, $body)
 Implements Mail_mail::send() function using php's built-in mail() command. More...
 
- Public Member Functions inherited from Mail
factory ($driver, $params=array())
 Provides an interface for generating Mail:: objects of various types. More...
 
 send ($recipients, $headers, $body)
 Implements Mail::send() function using php's built-in mail() command. More...
 
 _sanitizeHeaders (&$headers)
 Sanitize an array of mail headers by removing any additional header strings present in a legitimate header's value. More...
 
 prepareHeaders ($headers)
 Take an array of mail headers and return a string containing text usable in sending a message. More...
 
 parseRecipients ($recipients)
 Take a set of recipients and parse them, returning an array of bare addresses (forward paths) that can be passed to sendmail or an smtp server with the rcpt to: command. More...
 

Data Fields

 $_params = ''
 
- Data Fields inherited from Mail
 $sep = "\r\n"
 

Detailed Description

Definition at line 51 of file mail.php.

Member Function Documentation

◆ Mail_mail()

Mail_mail::Mail_mail (   $params = null)

Constructor.

Instantiates a new Mail_mail:: object based on the parameters passed in.

Parameters
array$paramsExtra arguments for the mail() function.

Definition at line 67 of file mail.php.

68  {
69  // The other mail implementations accept parameters as arrays.
70  // In the interest of being consistent, explode an array into
71  // a string of parameter arguments.
72  if (is_array($params)) {
73  $this->_params = join(' ', $params);
74  } else {
75  $this->_params = $params;
76  }
77 
78  /* Because the mail() function may pass headers as command
79  * line arguments, we can't guarantee the use of the standard
80  * "\r\n" separator. Instead, we use the system's native line
81  * separator. */
82  if (defined('PHP_EOL')) {
83  $this->sep = PHP_EOL;
84  } else {
85  $this->sep = (strpos(PHP_OS, 'WIN') === false) ? "\n" : "\r\n";
86  }
87  }

◆ send()

Mail_mail::send (   $recipients,
  $headers,
  $body 
)

Implements Mail_mail::send() function using php's built-in mail() command.

Parameters
mixed$recipientsEither a comma-seperated list of recipients (RFC822 compliant), or an array of recipients, each RFC822 valid. This may contain recipients not specified in the headers, for Bcc:, resending messages, etc.
array$headersThe array of headers to send with the mail, in an associative array, where the array key is the header name (ie, 'Subject'), and the array value is the header value (ie, 'test'). The header produced from those values would be 'Subject: test'.
string$bodyThe full text of the message body, including any Mime parts, etc.
Returns
mixed Returns true on success, or a PEAR_Error containing a descriptive error message on failure.

public

Definition at line 115 of file mail.php.

References $result, Mail\_sanitizeHeaders(), Mail\prepareHeaders(), and PEAR\raiseError().

116  {
117  if (!is_array($headers)) {
118  return PEAR::raiseError('$headers must be an array');
119  }
120 
121  $result = $this->_sanitizeHeaders($headers);
122  if (is_a($result, 'PEAR_Error')) {
123  return $result;
124  }
125 
126  // If we're passed an array of recipients, implode it.
127  if (is_array($recipients)) {
128  $recipients = implode(', ', $recipients);
129  }
130 
131  // Get the Subject out of the headers array so that we can
132  // pass it as a seperate argument to mail().
133  $subject = '';
134  if (isset($headers['Subject'])) {
135  $subject = $headers['Subject'];
136  unset($headers['Subject']);
137  }
138 
139  // Also remove the To: header. The mail() function will add its own
140  // To: header based on the contents of $recipients.
141  unset($headers['To']);
142 
143  // Flatten the headers out.
144  $headerElements = $this->prepareHeaders($headers);
145  if (is_a($headerElements, 'PEAR_Error')) {
146  return $headerElements;
147  }
148  list(, $text_headers) = $headerElements;
149 
150  // We only use mail()'s optional fifth parameter if the additional
151  // parameters have been provided and we're not running in safe mode.
152  if (empty($this->_params) || ini_get('safe_mode')) {
153  $result = mail($recipients, $subject, $body, $text_headers);
154  } else {
155  $result = mail($recipients, $subject, $body, $text_headers,
156  $this->_params);
157  }
158 
159  // If the mail() function returned failure, we need to create a
160  // PEAR_Error object and return it instead of the boolean result.
161  if ($result === false) {
162  $result = PEAR::raiseError('mail() returned failure');
163  }
164 
165  return $result;
166  }
$result
_sanitizeHeaders(&$headers)
Sanitize an array of mail headers by removing any additional header strings present in a legitimate h...
Definition: Mail.php:153
prepareHeaders($headers)
Take an array of mail headers and return a string containing text usable in sending a message...
Definition: Mail.php:178
& raiseError($message=null, $code=null, $mode=null, $options=null, $userinfo=null, $error_class=null, $skipmsg=false)
This method is a wrapper that returns an instance of the configured error class with this object's de...
Definition: PEAR.php:524
+ Here is the call graph for this function:

Field Documentation

◆ $_params

Mail_mail::$_params = ''

Definition at line 57 of file mail.php.


The documentation for this class was generated from the following file: