61 if (isset($params[
'sendmail_path'])) {
62 $this->sendmail_path = $params[
'sendmail_path'];
64 if (isset($params[
'sendmail_args'])) {
65 $this->sendmail_args = $params[
'sendmail_args'];
73 if (defined(
'PHP_EOL')) {
76 $this->sep = (strpos(PHP_OS,
'WIN') ===
false) ?
"\n" :
"\r\n";
105 function send($recipients, $headers, $body)
107 if (!is_array($headers)) {
112 if (is_a(
$result,
'PEAR_Error')) {
117 if (is_a($recipients,
'PEAR_Error')) {
120 $recipients = implode(
' ', array_map(
'escapeshellarg', $recipients));
123 if (is_a($headerElements,
'PEAR_Error')) {
124 return $headerElements;
126 list($from, $text_headers) = $headerElements;
131 if (!empty($headers[
'Return-Path'])) {
132 $from = $headers[
'Return-Path'];
137 } elseif (strpos($from,
' ') !==
false ||
138 strpos($from,
';') !==
false ||
139 strpos($from,
'&') !==
false ||
140 strpos($from,
'`') !==
false) {
141 return PEAR::raiseError(
'From address specified with dangerous characters.');
144 $from = escapeshellarg($from);
146 $mail = @popen($this->sendmail_path . (!empty($this->sendmail_args) ?
' ' . $this->sendmail_args :
'') .
" -f$from -- $recipients",
'w');
148 return PEAR::raiseError(
'Failed to open sendmail [' . $this->sendmail_path .
'] for execution.');
153 fputs($mail, $text_headers . $this->sep . $this->sep);
157 if (version_compare(phpversion(),
'4.2.3') == -1) {
Mail_sendmail($params)
Constructor.
send($recipients, $headers, $body)
Implements Mail::send() function using the sendmail command-line binary.
parseRecipients($recipients)
Take a set of recipients and parse them, returning an array of bare addresses (forward paths) that ca...
_sanitizeHeaders(&$headers)
Sanitize an array of mail headers by removing any additional header strings present in a legitimate h...
internal PHP-mail() implementation of the PEAR Mail:: interface.
prepareHeaders($headers)
Take an array of mail headers and return a string containing text usable in sending a message...
& 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...