| [ Index ] |
PHP Cross Reference of Akelos Framework |
[Summary view] [Print] [Text view]
1 <?php 2 3 4 class AkSmtpDelivery extends AkObject 5 { 6 function deliver(&$Mailer, $settings = array()) 7 { 8 $Message =& $Mailer->Message; 9 10 $SmtpClient =& Mail::factory('smtp', $settings); 11 12 include_once 'Net/SMTP.php'; 13 14 if (!($smtp = &new Net_SMTP($SmtpClient->host, $SmtpClient->port, $SmtpClient->localhost))) { 15 return PEAR::raiseError('unable to instantiate Net_SMTP object'); 16 } 17 18 if ($SmtpClient->debug) { 19 $smtp->setDebug(true); 20 } 21 22 if (PEAR::isError($smtp->connect($SmtpClient->timeout))) { 23 trigger_error('unable to connect to smtp server '.$SmtpClient->host.':'.$SmtpClient->port, E_USER_NOTICE); 24 return false; 25 } 26 27 if ($SmtpClient->auth) { 28 $method = is_string($SmtpClient->auth) ? $SmtpClient->auth : ''; 29 30 if (PEAR::isError($smtp->auth($SmtpClient->username, $SmtpClient->password, $method))) { 31 trigger_error('unable to authenticate to smtp server', E_USER_ERROR); 32 } 33 } 34 35 $from = is_array($Message->from) ? array_shift(array_values($Message->from)) : $Message->from; 36 37 if (PEAR::isError($smtp->mailFrom($from))) { 38 trigger_error('unable to set sender to [' . $from . ']', E_USER_ERROR); 39 } 40 41 $recipients = $SmtpClient->parseRecipients($Message->getRecipients()); 42 43 if (PEAR::isError($recipients)) { 44 return $recipients; 45 } 46 47 foreach ($recipients as $recipient) { 48 if (PEAR::isError($res = $smtp->rcptTo($recipient))) { 49 return PEAR::raiseError('unable to add recipient [' . 50 $recipient . ']: ' . $res->getMessage()); 51 } 52 } 53 54 if (PEAR::isError($smtp->data($Mailer->getRawMessage()))) { 55 return PEAR::raiseError('unable to send data'); 56 } 57 58 $smtp->disconnect(); 59 } 60 } 61 62 63 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Oct 27 12:43:49 2008 | Cross-referenced by PHPXref 0.6 |