Zend_Mail does not send email, displays a message: connection timeout

I am trying to write email sending codes using the Zend Framework. Here is the code

$mail = new Zend_Mail('utf-8');
$mailConfig = array(
'auth'=> 'login',
'username'  => 'sample@gmail.com',
'password'  => 'samplepassword',
'ssl'       => 'tls',
'port'      => '587';

$tr = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $mailConfig);
Zend_Mail::setDefaultTransport($tr);

$mail->setSubject('test email');
$mail->setBodyText('body');

$mail->setFrom('sample@gmail.com', 'Just a sample');

$mail->addTo('anothersample@gmail.com', 'Another sample');

$mail->send();

These codes work fine on my local computer, but I couldn’t send the server-side email with the return message “Connection time”. I assume that there might be a server-side configuration issue, but I don't know what it is. Anyone with an idea what is going wrong?

+3
source share
2 answers

, 587.
, .

+1

'ssl'='ssl' 995.

+2

Source: https://habr.com/ru/post/1735568/


All Articles