views:

265

answers:

1

Hi

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'  => '[email protected]',
'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('[email protected]', 'Just a sample');

$mail->addTo('[email protected]', '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?

A: 

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

michal kralik
i've contacted the admin. port number 587 is not block. any other suggestion?
Willy
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.
michal kralik