Send custom email in Magento

Send custom email in Magento – Sometimes, you want to create a function that can send an email without using the built-in email feature of Magento. Let’s find out how to do that.

All things we need to to:

  • Create an email template which is a html file.
  • Declare that email template in config.xml file
  • Build your own send email function.

Let’s do it step by step.

1. Create an email template.

Create file: /app/locale/en_US/template/email/yourmodulename/sample_email.html with simple content:

You can use your own template name and your store locale instead of “en_US”

2. Declare that email template in config.xml file.

3. Create your own send email function using the email template.

You can place it anywhere you want.

 

You can review function ‘sendTransactional‘ of class ‘Mage_Core_Model_Email_Template‘ for details:

 

Leave a Reply

Your email address will not be published.