Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-21-2008, 10:58 AM   PM User | #1
eeijlar
New Coder

 
Join Date: Feb 2006
Posts: 61
Thanks: 11
Thanked 0 Times in 0 Posts
eeijlar is an unknown quantity at this point
Send SMTP Mail With Gmail

Hi,

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

PHP Code:

$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:

Code:
a2enmod php5_ssl
I am not sure if I need to get Apache to load this up as a module.. Any ideas?
eeijlar is offline   Reply With Quote
Old 07-23-2008, 05:18 PM   PM User | #2
eeijlar
New Coder

 
Join Date: Feb 2006
Posts: 61
Thanks: 11
Thanked 0 Times in 0 Posts
eeijlar is an unknown quantity at this point
For anyone that's interested, the following code works:

Code:
$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...
eeijlar is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:08 PM.


Advertisement
Log in to turn off these ads.