我在var目录中创建了一个单独的php文件,用于cron作业。我添加了zend邮件功能,但它没有工作,也没有给出任何错误。
ini_set('display_errors', 1);
error_reporting(E_ALL);
require_once('app/Mage.php'); //Path to Magento
require_once('lib/Zend/Mail.php');
require_once('lib/Zend/Mail/Transport/Smtp.php');
umask(0);
Mage::app();
$mail = new Zend_Mail();
$mail->addTo('[email protected]','apple');
$mail->setFrom('[email protected]','sender');
$mail->setSubject('notifications');
$mail->setBodyHTML('<p>hi</p>','UTF-8'); // your content or message
try {
$mail->send();
echo "mail sent";
}
catch (Exception $e) {
print_r($e);
}
我假设您的var目录是公共的,添加自动加载路径
require getcwd() . '/../vendor/autoload.php'; // configure autoload path as per your file location.
ini_set('display_errors', 1);
error_reporting(E_ALL);
require_once('app/Mage.php'); //Path to Magento, may be this not required.
umask(0);
Mage::app();
$mail = new Zend_Mail();
$mail->addTo('[email protected]','apple');
$mail->setFrom('[email protected]','sender');
$mail->setSubject('notifications');
$mail->setBodyHTML('<p>hi</p>','UTF-8'); // your content or message
try {
$mail->send();
echo "mail sent";
}
catch (Exception $e) {
print_r($e);
}