【发布时间】:2013-12-31 04:43:45
【问题描述】:
我编写了一个用于发送邮件的脚本,它被发送到正确的电子邮件地址,但是以 HTML 代码的形式,我不知道为什么它不能工作,因为相同的代码在 Joomla 2.5 中工作正常。
这是我的代码:
$mailer = JFactory::getMailer();
$config = JFactory::getConfig();
$subject = 'Account Created';
$from = $config->get('mailfrom');
$fromname = $config->get( 'fromname' );
$body = "<p>Hello Test F,</p><br/><p>Thank you for registering at Deals&offers. Your account is created and activated.</p><br/>You may login to ".JURI::root().'index.php'." using the following username and password:</br><p>Username: ".$fname."</p><p>Password: ".$pwd."/p><br/><p><b>Note:</b> It is recomended to change your password after first login.</p>";
$sender = array(
$from,
$fromname
);
$mailer->setSender($sender);
$mailer->addRecipient($buyerEmail);
$mailer->setSubject($subject);
$mailer->setBody($body);
$send = $mailer->Send();
if ( $send !== true ) {
echo 'Error sending email: ' . $send->message;
} else {
echo 'Mail sent';
}
我也尝试了下面的方法,但得到了相同的结果。
JFactory::getMailer()->sendMail($from,$fromname,$buyerEmail, $subject, $body);
我在邮件中得到的输出是:
<p>Hello Test F,</p><br/><p>Thank you for registering at Deals&offers. Your account is created and activated.</p><br/>You may login to http://server.ashoresystems.com/~dealsand/index.php using the following username and password:</br><p>Username: rowdy</p><p>Password: lX1XZghF/p><br/><p><b>Note:</b> It is recomended to change your password after first login.</p>
我不确定我做错了什么。如果有人有任何解决方案,请帮忙。
【问题讨论】:
-
我不熟悉任何 joomla 版本,但我认为您必须手动指定正文类型。可能是旧版本手动检测它,但在新版本中没有。试试
$mailer->isHTML(true)(here example)
标签: php email joomla joomla3.2