在magento中發郵件


1. 在system->Configuration->Store Email Addresses中設置General Contact的Sender Name、Sender Email。

  Sender Name是郵件的發件人,Sender Email是發件人的郵件地址

2. 在system->Configuration->system中配置Mail Sending Settings,其配置如下

目前我也不明白Set Return-Path的作用,日后再添加說明

3. 重寫Mage_Core_Model_Email_Template(app/code/core/Mage/Core/Model/Email/Template.php)中的getmail()方法,

 public function getMail()
    {
        if (is_null($this->_mail)) {
            $my_smtp_host = Mage::getStoreConfig('system/smtp/host');
             $my_smtp_port = Mage::getStoreConfig('system/smtp/port');
             $config = array(
                         'port' => $my_smtp_port,
                         'auth' => 'login',                   
                        'username' => 'SMTP服務器的用戶名',
                         'password' => 'SMTP服務器的密碼'
             );
            $transport = new Zend_Mail_Transport_Smtp($my_smtp_host, $config);
            Zend_Mail::setDefaultTransport($transport);
            /* Changes End */
            $this->_mail = new Zend_Mail('utf-8');
        }
        return $this->_mail;
    }

4. 修改郵件模板

  magento默認的郵件模板位於app/locale/en_US/template/email中,系統根據當前的store調用不通語言下的模板

  (1) 在system->Transactional Emails中添加郵件模板,並在system->Configuration->Customer Configuration->Create New Account Options中選擇相應的模板


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM