SMTP email code magento

This tutorial explains how to configure SMTP email code magento 1.9.

SMTP email code magento

 public function getMail( $html )
    {
        try {

            $smtp_host = Mage::getStoreConfig('smtppro/general/smtp_host');
            $smtp_port = Mage::getStoreConfig('smtppro/general/smtp_port');
            $config = array(
                'port' => $smtp_port,
                'auth' => 'login',
                'ssl' => Mage::getStoreConfig('smtppro/general/smtp_ssl'),
                'username' => Mage::getStoreConfig('smtppro/general/smtp_username'),
                'password' => Mage::getStoreConfig('smtppro/general/smtp_password')
            );
            $transport = new Zend_Mail_Transport_Smtp($smtp_host,$config);
            Zend_Mail::setDefaultTransport($transport);
            $this->_mail = new Zend_Mail('utf-8');
            $this->_mail->setBodyText($html);
            $this->_mail->setFrom(Mage::getStoreConfig('call_back/call_back_details/from_email_address'),
                                  Mage::getStoreConfig('call_back/call_back_details/send_email_name'));
            $this->_mail->addTo(Mage::getStoreConfig('call_back/call_back_details/send_email'),
                                Mage::getStoreConfig('call_back/call_back_details/from_email_name'));
            $this->_mail->setSubject(Mage::getStoreConfig('call_back/call_back_details/mail_subject'));
            $this->_mail->send($transport);
            Mage::getSingleton('core/session')->addSuccess('Your request has been sent');


        }
        catch (Exception $e) {
            echo $e->getMessage();
            Mage::getSingleton('core/session')->addError('Unable to send.');
        }


    }

Share this Tutorial

Leave a Reply

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

*