Sometimes we wants to create a form and want to send the form information through the email in Magento. Here in this post I am trying to describe how we can send an email by using the Zend_Mail()?. It is very easy and there is predefined function in Magento to send the information through emails
Below is the code :
<?php
public function sendEmail()
{
$fromEmail = "from@abc.com"; // sender email address
$fromName = "EWA"; // sender name
$toEmail = "to@abc.com"; // recipient email address
$toName = "EWA1"; // recipient name
$body = "This is Test Email!"; // body text
$subject = "Test Subject1"; // subject text
$mail = new Zend_Mail();
$mail->setBodyText($body);
$mail->setFrom($fromEmail, $fromName);
$mail->addTo($toEmail, $toName);
$mail->setSubject($subject);
try {
$mail->send();
}
catch(Exception $ex) {
Mage::getSingleton('core/session')
->addError(Mage::helper('yourmodulename') //Your custom module name
->__('Unable to send email.'));
}
}
?>
Read More Regarding the PHP Email Click Here
Hope this would be helpfull, Keep reading and enjoy the Magento coding.



