| version 1.1, 2005/06/05 12:13:52 |
version 1.2, 2005/11/07 20:37:10 |
|
|
| * @return object Mail a instance of the driver class or if fails a PEAR Error |
* @return object Mail a instance of the driver class or if fails a PEAR Error |
| * @access public |
* @access public |
| */ |
*/ |
| function factory($driver, $params = array()) |
function &factory($driver, $params = array()) |
| { |
{ |
| $driver = strtolower($driver); |
$driver = strtolower($driver); |
| @include_once 'Mail/' . $driver . '.php'; |
@include_once 'Mail/' . $driver . '.php'; |
| $class = 'Mail_' . $driver; |
$class = 'Mail_' . $driver; |
| if (class_exists($class)) { |
if (class_exists($class)) { |
| return new $class($params); |
$mailer = new $class($params); |
| |
return $mailer; |
| } else { |
} else { |
| return PEAR::raiseError('Unable to find class for driver ' . $driver); |
return PEAR::raiseError('Unable to find class for driver ' . $driver); |
| } |
} |
|
|
| |
|
| $lines[] = $key . ': ' . $value; |
$lines[] = $key . ': ' . $value; |
| } elseif (strcasecmp($key, 'Received') === 0) { |
} elseif (strcasecmp($key, 'Received') === 0) { |
| |
$received = array(); |
| |
if (is_array($value)) { |
| |
foreach ($value as $line) { |
| |
$received[] = $key . ': ' . $line; |
| |
} |
| |
} |
| |
else { |
| |
$received[] = $key . ': ' . $value; |
| |
} |
| // Put Received: headers at the top. Spam detectors often |
// Put Received: headers at the top. Spam detectors often |
| // flag messages with Received: headers after the Subject: |
// flag messages with Received: headers after the Subject: |
| // as spam. |
// as spam. |
| array_unshift($lines, $key . ': ' . $value); |
$lines = array_merge($received, $lines); |
| } else { |
} else { |
| // If $value is an array (i.e., a list of addresses), convert |
// If $value is an array (i.e., a list of addresses), convert |
| // it to a comma-delimited string of its elements (addresses). |
// it to a comma-delimited string of its elements (addresses). |