基于Joomla!文档@ http://docs.joomla.org/Sending_email_from_extensions,我正在尝试使用以下代码发送电子邮件:
function sendmail($file,$mailto)
{
$mailer =& JFactory::getMailer();
//var_dump($mailer); exit;
$config =&JFactory::getConfig();
$sender = array(
$config->getValue( 'config.mailfrom' ),
$config->getValue( 'config.fromname' )
);
$mailer->setSender($sender);
$recipient = array($mailto);
$mailer->addRecipient($recipient);
$body = "Your body string\nin double quotes if you want to parse the \nnewlines etc";
$mailer->setSubject('Your subject string');
$mailer->setBody($body);
// Optional file attached
$mailer->addAttachment(JPATH_BASE.DS.'CSV'.DS.$file);
$send =&$mailer->Send();
if ( $send !== true ) {
echo 'Error sending email: ' . $send->message;
} else {
echo 'Mail sent';
}
}
($file
是文件 zip 的完整路径,$mailto
是我的 gmail。)
但是,当我发送邮件时,我收到错误:
无法实例化邮件功能。
致命错误:无法访问第 142 行 /var/www/html/dai/components/com_servicemanager/views/i0602/view.html.php 中的受保护属性 JException::$message
是什么导致了这个错误?