Tuesday , December 12 2017
Home >> All tutorial >> Sending Email in Magento

Sending Email in Magento

Anyone can send mail using php mail() function. But in magento, all the functionality you need to just send argument inside those functions. See the following code to send mail using magento function:

  1. <?php 
  2. $mail = Mage::getModel(‘core/email’);
  3. $mail->setToName(‘Your Name’);
  4. $mail->setToEmail(‘Youe Email’);
  5. $mail->setBody(‘Mail Text / Mail Content’);
  6. $mail->setSubject(‘Mail Subject’);
  7. $mail->setFromEmail(‘Sender Mail Id’);
  8. $mail->setFromName(“Msg to Show on Subject”);
  9. $mail->setType(‘html’);// YOu can use Html or text as Mail format
  10.  
  11. try {
  12. $mail->send();
  13. Mage::getSingleton(‘core/session’)->addSuccess(‘Your request has been sent’);
  14. $this->_redirect();
  15. }
  16. catch (Exception $e) {
  17. Mage::getSingleton(‘core/session’)->addError(‘Unable to send.’);
  18. $this->_redirect();
  19. }
  20. ?>

Thank for your attention. Read more about Magento Email Templates here.

We also contribute great content of Magento Download for FREE (all versions)

DON'T MISS THE CHANCE!

magento download

About Champ

Leave a Reply

Your email address will not be published. Required fields are marked *

Heap | Mobile and Web Analytics