1
你好,我一直在嘗試發送一個郵件在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 = "[email protected]";
$fromName = "PRODUCT ALERTS";
$toEmail = "[email protected]";
$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();
}
}
'到目前爲止我還沒有收到一封電子郵件' - 意思是什麼?你的Magento/Apache/Postfix錯誤日誌中有什麼? – 2012-02-26 02:51:18
任何日誌中都沒有消息,並且不會回顯任何內容。 Magento確實發送內部電子郵件,但我似乎無法使此功能起作用。謝謝 - – 2012-02-26 02:56:56
你在運行這個腳本的操作系統是什麼?你有沒有正確安裝PostFix並進行配置?什麼是內部電子郵件? – 2012-02-26 16:18:48