2009-07-22 17 views
1

有没有人成功发送邮件(SMTP GOOGLE)与Zend_Log.I发现此http://framework.zend.com/manual/en/zend.log.writers.html 第32.2.4章。写电子邮件但默认情况下它使用电子邮件(),但我想用SMTP.So到现在为止我的代码看起来是这样的:Zend_Log与邮件

$mailconf = array('ssl'=>'ssl', 
      'auth' => 'login', 
        'username' => '[email protected]', 
        'password' => 'mypass', 
        'port'=>'465');  
$transport = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $mailconf);     


    $mail = new Zend_Mail(); 
    $mail->setFrom('[email protected]') 
     ->addTo('[email protected]'); 

    $writer = new Zend_Log_Writer_Mail($mail); 
    // On fixe le sujet du mail 
    $writer->setSubjectPrependText('Important Log Events'); 

    // Only email warning level entries and higher. 
    $writer->addFilter(Zend_Log::WARN); 

    $loggerZendMail = new Zend_Log(); 
    $loggerZendMail->addWriter($writer); 

    $loggerZendMail->log('unable to connect to database',Zend_Log::WARN); 

我得到这个错误:

Fatal error: Uncaught exception 'Zend_Log_Exception' with message 'Unable to send mail' in C:\wamp\www\zf_log\Zend\Log\Writer\Mail.php:256 Stack trace: #0 C:\wamp\www\zf_log\Zend\Log.php(84): Zend_Log_Writer_Mail->shutdown() #1 C:\wamp\www\zf_log\Zend\Controller\Action.php(512): Zend_Log->__destruct() #2 C:\wamp\www\zf_log\Zend\Controller\Action.php(512): IndexController->indexAction() #3 C:\wamp\www\zf_log\Zend\Controller\Dispatcher\Standard.php(288): Zend_Controller_Action->dispatch('indexAction') #4 C:\wamp\www\zf_log\Zend\Controller\Front.php(945): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #5 C:\wamp\www\zf_log\index.php(30): Zend_Controller_Front->dispatch() #6 {main} thrown in C:\wamp\www\zf_log\Zend\Log\Writer\Mail.php on line 256

有什么建议吗?

回答

0

我会检查服务器上是否启用了SMTP。

2

您需要设置交通为的Zend_Mail使用

例子:


Zend_Mail::setDefaultTransport($transport); 
 
0

使用TLS而非SSL还检查该端口是否587工程

所以下面的配置应该工作

$mailconf = array('ssl'=>'tls', 'auth' => 'login', 'username' => '[email protected]', 'password' => 'mypass', 'port'=>'587');