Wednesday , November 14 2018
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
  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.

Here is the library of Magento Download for FREE (all versions)

Your Magento website needs a powerful Magento ERP for stock control.


magento erp

About Champ

Leave a Reply

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

Heap | Mobile and Web Analytics