当用户注册时,我正在尝试从我的组件发送邮件。我尝试了所有三个,即 PHPMail、Sendmail 和 SMTP,但都没有。我在 localhost (WampServer 2.2) 中测试它,Joomla 版本是 2.5.4。我不确定这是 WampServer 问题还是 Joomla 或我自己的代码。这是我的代码:
function postmail($name, $receiver){
jimport('joomla.mail.helper');
$mailer =& JFactory::getMailer();
$config =& JFactory::getConfig();
$sender = array($config->getValue( 'config.mailfrom'),$config->getValue( 'config.fromname' ) );
$mailer->setSender($sender);
$recipient = $receiver;
$mailer->addRecipient($recipient);
$body = "<body><br><p>";
$body .= "<strong>$name,</strong> ";
$body .= "</p><br></body>";
$mailer->isHTML(true);
$mailer->Encoding = 'base64';
$mailer->setBody($body);
$send =& $mailer->Send();
if ( $send != true ) {
//echo 'Error sending email: ' . $send->message;
return false;
} else {
//echo 'Mail sent';
return true;
}
}
它收到错误“无法实例化邮件功能”。