2013-07-22 3 views
3

gmail SMTP를 사용하여 전자 메일을 보내려고합니다. 다음은 내 코드입니다.gmail SMTP를 사용하여 전자 메일을 Zend

$mail = new Zend_Mail(); 
$config = array(
      'ssl'  => 'ssl', 
      'port'  => '465', 
      'auth'  => 'login', 
      'username' => '[email protected]', 
      'password' => 'mypassword' 
     ); 

$transport = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $config); 
$sendNow = $mail->setBodyHtml($message) 
        ->setFrom('[email protected]', 'abc def') 
        ->addTo($recipient) 
        ->setSubject($subject) 
        ->send($transport); 

그러나 다음 오류가 발생합니다. 어떻게 할 수 있습니까?

Fatal error: Uncaught exception 'Zend_Mail_Protocol_Exception' with message 'Unable to find the socket transport 'ssl' - did you forget to enable it when you configured PHP?' in Implementation\trunk\webapp\library\Zend\Mail\Protocol\Abstract.php:277

+1

은 SSL의 확장자가 활성화되어 있습니까? –

답변

2

은 Gmail에 대한 귀하의 구성은 광산 다르게 설정되어 있습니다. 다음은 내가 사용하는 것입니다 :

$config = array(
      'host' => 'smtp.gmail.com', 
      'port' => 587, 
      'ssl' => 'tls', 
      'auth' => 'login', 
      'username' => '*****', 
      'password' => '*****', 
     ); 

'ssl'과 'port'의 차이점에 유의하십시오.

다음
7

젠드 메일 내 코드는이 .....

$config = array('ssl' => 'tls', 
       'auth' => 'login', 
       'username' => '[email protected]', 
       'password' => 'password'); 

    $transport = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $config); 

    $mail = new Zend_Mail(); 
    $mail->setBodyHtml($bodytext); 
    $mail->setFrom('[email protected]'); 
    $mail->addTo($email, $username); 
    $mail->setSubject('Profile Activation'); 
    $mail->send($transport); 

그리고 지금 제대로 작동 ...

관련 문제