Sending Simple Email using Magento

Sending Simple Email in Magento

ini_set('display_errors',1);
require_once('../../app/Mage.php');
umask(0);
Mage::app('admin');
$port = 465; //465,587
$ssl = "TLS"; // SSL/TLS
$username = "server@example.com";
$password = "password";
$host = "secure.emailsrvr.com"; // for Google host will be smtp.gmail.com
$config = array('ssl' => $ssl, 'port' => $port, 'auth' => 'login', 'username' => $username, 'password' => $password);
$smtpConnection = new Zend_Mail_Transport_Smtp($host, $config);
$mail = new Zend_Mail();
$mail->setBodyText('This is the text of the mail.');
$mail->setFrom('from@example.com', 'From');
$mail->addTo('to@example.com', 'To');
$mail->setSubject('TestSubject');
$mail->send($smtpConnection);

Was this article helpful?

Related Articles

Leave A Comment?

You must be logged in to post a comment.