邮件内容在 Joomla 3 中显示为 html 代码

Mail content shows as html code in Joomla 3(邮件内容在 Joomla 3 中显示为 html 代码)
本文介绍了邮件内容在 Joomla 3 中显示为 html 代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个发送邮件的脚本,它被发送到正确的电子邮件地址,但以 HTML 代码的形式,我不知道为什么它不工作,因为相同的代码在 Joomla 2.5 中工作正常.

I have written a script for sending a mail, it gets delivered to the correct email address but in them form of HTML code, I don't know why it's not working as same code is working fine in 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';
}

我也像下面这样尝试过,但得到了相同的结果.

I have also tried like below, but got same result.

JFactory::getMailer()->sendMail($from,$fromname,$buyerEmail, $subject, $body);

我在邮件中得到的输出是:

the output I got in the mail is:

<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>

我不确定我做错了什么.如果有人有任何解决方案,请帮忙.

I am not sure what I am doing wrong. If anyone has any solution please help.

推荐答案

试试这个..

对于你的第一种方法......你必须设置

For your first method...You have to set

$mailer->isHTML(true);

参考:http://docs.joomla.org/Sending_email_from_extensions

对于您的第二种方法...

For your second method...

发送邮件功能:

sendMail($from, $fromname, $recipient, $subject, $body, $htmlmode=0, $cc=null, $bcc=null, $attachment=null, $replyto=null, $replytoname=null )

所以你的代码应该是

JFactory::getMailer()->sendMail($from,$fromname,$buyerEmail, $subject, $body,true);

这篇关于邮件内容在 Joomla 3 中显示为 html 代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Convert JSON integers and floats to strings(将JSON整数和浮点数转换为字符串)
in php how do I use preg replace to turn a url into a tinyurl(在php中,如何使用preg替换将URL转换为TinyURL)
all day appointment for ics calendar file wont work(ICS日历文件的全天约会不起作用)
trim function is giving unexpected values php(Trim函数提供了意外的值php)
Basic PDO connection to MySQL(到MySQL的基本PDO连接)
PHP number_format returns 1.00(Php number_Format返回1.00)