Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Feb 2006
    Posts
    61
    Thanks
    11
    Thanked 0 Times in 0 Posts

    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?

  • #2
    New Coder
    Join Date
    Feb 2006
    Posts
    61
    Thanks
    11
    Thanked 0 Times in 0 Posts
    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...


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •