我已经在用于cron作业的var目录中创建了一个单独的php文件。我添加了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('mymail@mail.com','apple');
$mail->setFrom('sender@mail.com','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);
}
答案 0 :(得分:0)
我认为您的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('mymail@mail.com','apple');
$mail->setFrom('sender@mail.com','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);
}