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) {