Magento Send Email Via SendGrid

SendGrid’s documentation suggest using the SMTP Pro Email free extension, but for some reason it didn’t want to install even though it supports the Magento version I have. After a little digging it turns out that there is one simple method to override in Magento Core, that will allow you to upgrade without losing your changes and send via SendGrid.

Change APP to the name or your app


<?xml version="1.0"?>


<?xml version="1.0"?>


 * extend magento getMail so that we can use the SendGrid smtp servers

class APP_SendGrid_Core_Model_Email_Template extends Mage_Core_Model_Email_Template {

     * Retrieve mail object instance
     * @return Zend_Mail
    public function getMail() {
        if (is_null($this->_mail)) {
            $config    = array(
                'ssl'      => 'tls',
                'port'     => 587,
                'auth'     => 'login',
                'username' => '<username>',
                'password' => '<password>'
            $transport = new Zend_Mail_Transport_Smtp('', $config);

            $this->_mail = new Zend_Mail('utf-8');

            // set a reporting category
            $category = array('category' => '<category>');
            $this->_mail->addHeader('X-SMTPAPI', json_encode($category, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP));
        return $this->_mail;

Once you have those three files in place, you can clear the Magento cache and see if the extension has been recognized.
Go to Magento Admin -> System -> Config -> Advanced and there you will see APP_SendGrid enabled.

Did you like this? Share it:
This entry was posted in Coding. Bookmark the permalink.
  • sandy


    I have follow your blog and integrate it with magento 1.8.1. But i am getting Fatal error Call to a member function addBcc() on a non-object.

    Please help me to resolve it.

    • Anton Visser

      @disqus_GdwMHdFcAt:disqus I ran into the same issue in one of my stores, but haven’t had time to figure it out. The work-around I use is to ‘send order email copy to’ and set ‘send order email copy method’ to ‘seperate email’

      Please let me know if you figure out a solution.