3

I try to write codes about sending email using 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 perfectly at my local computer, but failed to send email at the server side with return message "Connection time out". I guess there might be some configuration problem on the server side, but I don't know what it is. Anyone with idea what is going wrong?

Daniel Rikowski
  • 71,375
  • 57
  • 251
  • 329
Willy
  • 9,681
  • 5
  • 26
  • 25

2 Answers2

2

Try 'ssl'='ssl' and port 995.

Jérôme Verstrynge
  • 57,710
  • 92
  • 283
  • 453
L C
  • 21
  • 2
1

Contact the admin of the server and ask if they allow outgoing communication on port 587.
It seems like they are blocking certain traffic.

mike
  • 5,047
  • 2
  • 26
  • 32
  • i've contacted the admin. port number 587 is not block. any other suggestion? – Willy Mar 15 '10 at 21:36
  • If it's not the port, ask if they are not blocking emails in any way from PHP. What does the error message say exactly? Are you running in safe_mode? Try turning it off. – mike Mar 17 '10 at 16:23