branko ajzele, senior developer / project manager

Posts / Articles

Sending emails via Zend_Mail using Google email account

Here is a little (working) code example of how easy it is to send emails via Zend_Mail class using your existing Google email account.

<?php 
 
$emailSmtpConf = array(
	'auth' => 'login',
	'ssl' => 'tls',
    'username' => 'email2@domain.com',
    'password' => 'mypasshere'
);
 
$transport = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $emailSmtpConf);
 
$mail = new Zend_Mail();
$mail->addTo('email1@domain.com', 'Name 1');
$mail->setFrom('email2@domain.com', 'Name 2');
$mail->setSubject('Demo Email');
$mail->setBodyText('Email content here');
$mail->send($transport);
  • http://classyllama.com/ Erik Hansen

    If anyone needs to send emails from Magento using a Google Apps account, they should checkout this module: http://www.magentocommerce.com/extension/1326/aschroder.com-google-apps-email-gmail

  • http://classyllama.com Erik Hansen

    If anyone needs to send emails from Magento using a Google Apps account, they should checkout this module: http://www.magentocommerce.com/extension/1326/aschroder.com-google-apps-email-gmail

  • srinivas

    Hi Branko,

    I’ve used the exact code which you have provided here in my controller action.
    I got the below error:
    Fatal error: Maximum execution time of 30 seconds exceeded in C:Program FilesApache Software FoundationApache2.2htdocsTestlibraryZendMail ProtocolAbstract.php on line 321

    My System Env is:
    PHP 5.2.9 and Apache 2.2.11 on Windows XP professional SP3.

    Is there something i’m missing. Should i configure anything apart from using the given piece of code. Pls suggest..

    Regards,
    Srinivas

  • srinivas

    Hi Branko,

    I’ve used the exact code which you have provided here in my controller action.
    I got the below error:
    Fatal error: Maximum execution time of 30 seconds exceeded in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\Test\library\Zend\Mail \Protocol\Abstract.php on line 321

    My System Env is:
    PHP 5.2.9 and Apache 2.2.11 on Windows XP professional SP3.

    Is there something i’m missing. Should i configure anything apart from using the given piece of code. Pls suggest..

    Regards,
    Srinivas

blog comments powered by Disqus