使用模板在Magento下发送电子邮件

时间:2012-02-26 00:32:51

标签: php e-commerce magento

您好我一直在尝试使用模板和Zend框架发送magento中的电子邮件。到目前为止,我没有收到一封电子邮件。这就是我所拥有的。

define('MAGENTO', realpath(dirname(__FILE__)));
$new_stock_csv ="var/import/test.co/new_stock.csv";

require_once MAGENTO . '/app/Mage.php';
$currentStore = Mage::app()->getStore()->getId(); 

$mess = "Test of message to be in body."
product_change_email($mess,MAGENTO.$new_stock_csv);

function product_change_email($mess,$file){ 
    $fromEmail = "notice@gmail.com";
    $fromName = "PRODUCT ALERTS";
    $toEmail = "jeremybass@somewhere.net";
    $toName = "Jeremy Bass";
    $body = $mess;
    // body text
    $subject = "Test Subject";
    // subject text

    try{
        $mail = new Zend_Mail();
        $mail->setFrom($fromEmail, $fromName);
        $mail->addTo($toEmail, $toName);
        $mail->setSubject($subject);
        $mail->setBodyHtml($body); // here u also use setBodyText options.

        // this is for to set the file format
        $at = new Zend_Mime_Part($body);

        $at->type        = 'application/csv'; // if u have PDF then it would like -> 'application/pdf'
        $at->disposition = Zend_Mime::DISPOSITION_INLINE;
        $at->encoding    = Zend_Mime::ENCODING_8BIT;
        $at->filename    = $file;
        $mail->addAttachment($at);
        $mail->send();

    }catch(Exception $e){
        echo $e->getMassage();

    }
}

1 个答案:

答案 0 :(得分:0)

未正确安装修补程序。 tk Zachary Schuessler

相关问题