46 require_once
'PEAR.php';
74 function &
factory($driver, $params = array())
76 $driver = strtolower($driver);
77 @include_once
'Mail/' . $driver .
'.php';
78 $class =
'Mail_' . $driver;
79 if (class_exists($class)) {
80 $mailer =
new $class($params);
114 function send($recipients, $headers, $body)
116 if (!is_array($headers)) {
121 if (is_a($result,
'PEAR_Error')) {
126 if (is_array($recipients)) {
127 $recipients = implode(
', ', $recipients);
133 if (isset($headers[
'Subject'])) {
134 $subject = $headers[
'Subject'];
135 unset($headers[
'Subject']);
141 return mail($recipients, $subject, $body, $text_headers);
155 foreach ($headers as $key => $value) {
157 preg_replace(
'=((<CR>|<LF>|0x0A/%0A|0x0D/%0D|\\n|\\r)\S).*=i',
183 foreach ($headers as $key => $value) {
184 if (strcasecmp($key,
'From') === 0) {
185 include_once
'Mail/RFC822.php';
187 $addresses = $parser->parseAddressList($value,
'localhost',
false);
188 if (is_a($addresses,
'PEAR_Error')) {
192 $from = $addresses[0]->mailbox .
'@' . $addresses[0]->host;
195 if (strstr($from,
' ')) {
199 $lines[] = $key .
': ' . $value;
200 } elseif (strcasecmp($key,
'Received') === 0) {
202 if (is_array($value)) {
203 foreach ($value as $line) {
204 $received[] = $key .
': ' . $line;
208 $received[] = $key .
': ' . $value;
213 $lines = array_merge($received, $lines);
217 if (is_array($value)) {
218 $value = implode(
', ', $value);
220 $lines[] = $key .
': ' . $value;
224 return array($from, join($this->sep, $lines));
242 include_once
'Mail/RFC822.php';
246 if (is_array($recipients)) {
247 $recipients = implode(
', ', $recipients);
256 if (is_a($addresses,
'PEAR_Error')) {
260 $recipients = array();
261 if (is_array($addresses)) {
262 foreach ($addresses as $ob) {
263 $recipients[] = $ob->mailbox .
'@' . $ob->host;