Problem when sending mail with Zend Mail?

后端 未结 4 1684
予麋鹿
予麋鹿 2020-12-31 02:53

I\'m trying to send an e-mail with ZendMail ( this simple script sums it up )

se         


        
4条回答
  •  灰色年华
    2020-12-31 03:49

    Updated Goles answer need to add 'ssl' => 'tls', at top to avoid errors

    require_once('Zend/Mail/Transport/Smtp.php');
    require_once 'Zend/Mail.php';
    $config = array(
                    'ssl' => 'tls',
                    'auth' => 'login',
                    'username' => 'somemail@mysite.com',
                    'password' => 'somepass'
                    );
    
    $transport = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $config);
    
    $mail = new Zend_Mail();
    $mail->setBodyText('This is the text of the mail.');
    $mail->setFrom('somemail@mysite.com', 'Some Sender');
    $mail->addTo('somemail@mysite.com', 'Some Recipient');
    $mail->setSubject('TestSubject');
    $mail->send($transport);
    

提交回复
热议问题