3

Gmail SMTP を使用してメールを送信しようとしています。以下は私のコードです。

$mail = new Zend_Mail();
$config = array(
            'ssl'      => 'ssl',
            'port'     => '465',
            'auth'     => 'login',
            'username' => 'username@gmail.com',
            'password' => 'mypassword'
        );

$transport = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $config);
$sendNow   = $mail->setBodyHtml($message)
                  ->setFrom('username@gmail.com', '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

4

2 に答える 2

7

これがzend mailの私のコードです.....

    $config = array('ssl' => 'tls',
                'auth' => 'login',
                'username' => 'your@gmail.com',
                'password' => 'password');

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

    $mail = new Zend_Mail();
    $mail->setBodyHtml($bodytext);
    $mail->setFrom('your@gmail.com');
    $mail->addTo($email, $username);
    $mail->setSubject('Profile Activation');
    $mail->send($transport);

そして、それは現在正常に動作しています...

于 2013-10-18T11:41:46.310 に答える