...

View Full Version : Send SMTP Mail With Gmail



eeijlar
07-21-2008, 10:58 AM
Hi,

I am using code similar to this to try and send e-mail:




$config = array('auth' => 'login',
'username' => 'myaccount [at] gmail.com',
'password' => 'mypassword',
'ssl' => 'tls',
'port' => 587);

$userNotification = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $config);

$mail = new Zend_Mail();
$mail->setFrom('another [at] email.com','Another Email');
$mail->addHeader('another [at] email.com');
$mail->setReturnPath('another [at] email.com');
$mail->addTo($userEmail);
$mail->setSubject($usernotificationsubject);
$mail->setBodyText($usernotificationmessage);
$mail->send($userNotification);


When I try to send the e-mail I get an error about TLS. I have enabled SSL for PHP by typing the following:


a2enmod php5_ssl

I am not sure if I need to get Apache to load this up as a module.. Any ideas?

eeijlar
07-23-2008, 05:18 PM
For anyone that's interested, the following code works:


$config = array('auth' => 'login',
'username' => 'myaccount [at] gmail.com',
'password' => 'mypassword',
'ssl' => 'ssl',
'port' => 465);

$userNotification = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $config);

$mail = new Zend_Mail();
$mail->setFrom('another [at] email.com','Another Email');
$mail->addHeader('another [at] email.com');
$mail->setReturnPath('another [at] email.com');
$mail->addTo($userEmail);
$mail->setSubject($usernotificationsubject);
$mail->setBodyText($usernotificationmessage);
$mail->send($userNotification);


Also, install php5_ssl...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum