Sending Email in Magento in simple and easy steps

Posted on Updated on

Sending Email in Magento in simple and easy steps
Put this in your controller function from where u want to send an email.

<?php
public function sendMailAction(){
$html=put your html content here";
$mail = Mage::getModel('core/email');
$mail->setToName('Your Name');
$mail->setToEmail('Youe Email');
$mail->setBody($html);
$mail->setSubject('Mail Subject');
$mail->setFromEmail('Sender Mail Id');
$mail->setFromName("Msg to Show on Subject");
$mail->setType('html');// YOu can use Html or text as Mail format
try {
$mail->send();
Mage::getSingleton('core/session')->addSuccess('Your request has been sent');
$this->_redirect('');
}
catch (Exception $e) {
Mage::getSingleton('core/session')->addError('Unable to send.');
$this->_redirect('');
}
}
?>

Cheers!!

Advertisements

2 thoughts on “Sending Email in Magento in simple and easy steps

    mageblog said:
    March 26, 2012 at 5:25 PM

    this is was a searched for ! thanks !

    Amir Iqbal said:
    May 4, 2015 at 6:05 AM

    Awesome.. Very Helpful..

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s