Gmail uses secure connection with TLS, so you configuration should look
like this:
$config = array('auth' => 'login',
'username' => 'myusername',
'password' => 'password',
'ssl' => 'tls' );
$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('sender@test.com', 'Some Sender');
$mail->addTo('recipient@test.com', 'Some Recipient');
$mail->setSubject('TestSubject');
$mail->send($transport);
Best regards,
Nayef Abu Ebaid
Jigal sanders wrote:
> Hello all,
>
> I Am triying to get Zend_Mail working via SMTP but I get the following
> error:
>
> exception 'Zend_Mail_Protocol_Exception' with message '530 5.7.0 Must
> issue a STARTTLS command first. j27sm350573ugc.7 ' in
> /var/www/library/Zend/Mail/Protocol/Abstract.php:378 Stack trace: #0
> /var/www/library/Zend/Mail/Protocol/Smtp.php(261):
> Zend_Mail_Protocol_Abstract->_expect(250, 300) #1
> /var/www/library/Zend/Mail/Transport/Smtp.php(205):
> Zend_Mail_Protocol_Smtp->mail('jigalroecha@gma...') #2
> /var/www/library/Zend/Mail/Transport/Abstract.php(348):
> Zend_Mail_Transport_Smtp->_sendMail() #3
> /var/www/library/Zend/Mail.php(721):
> Zend_Mail_Transport_Abstract->send(Object(Zend_Mail)) #4
> /var/www/application/admin/models/MailHandler.php(18):
> Zend_Mail->send(Object(Zend_Mail_Transport_Smtp)) #5
> /var/www/application/admin/controllers/EvenementController.php(41):
> MailHandler->__construct() #6
> /var/www/library/Zend/Controller/Action.php(502):
> Admin_EvenementController->testAction() #7
> /var/www/library/Zend/Controller/Dispatcher/Standard.php(293):
> Zend_Controller_Action->dispatch('testAction') #8
> /var/www/library/Zend/Controller/Front.php(946):
> Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http),
> Object(Zend_Controller_Response_Http)) #9
> /var/www/public/Bootstrap.php(11): Zend_Controller_Front->dispatch()
> #10 /var/www/public/index.php(22): Bootstrap::run() #11 {main}
>
> Here is my code:
>
> class MailHandler{
>
> public function __construct(){
> $config = array('auth' => 'login',
> 'username' => 'myadress@gmail.com
> <mailto:myadress@gmail.com> ',
> 'password' => 'mypassword');
> $transport = new Zend_Mail_Transport_Smtp('smtp.gmail.com
> <http://smtp.gmail.com>');
> Zend_Mail::setDefaultTransport($transport);
> $mail = new Zend_Mail();
> $mail->setBodyText('This is the text of the mail.');
> $mail->setFrom('jigalroecha@gmail.com <mailto:jigalroecha@gmail.com>',
> 'Some Sender');
> $mail->addTo('roechama@htomail.com <mailto:roechama@htomail.com>',
> 'j.js@inter.nl.net <mailto:j.js@inter.nl.net>');
> $mail->setSubject('TestSubject');
> $mail->send($transport);
>
> }
>
>
>
>
>
> }
>
> I am not running php in save mode and I am running on Zend framework 1.6.0
>
> Thanks in advance!
>
> J. Sanders
没有评论:
发表评论