简体   繁体   English

为什么 HTML 电子邮件只是在 php 中显示代码

[英]Why HTML email is just showing code in php

Why HTML email is just showing code in php email.为什么 HTML 电子邮件只是在 php 电子邮件中显示代码。 I am trying to send the email through php using elasticemail but showing the just code.我正在尝试使用 elasticemail 通过 php 发送电子邮件,但显示了正确的代码。 I found somewhere that I should add the header like this.我发现我应该像这样添加标题。 but the problem is i am not able to understand how can I add this code.但问题是我无法理解如何添加此代码。

$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

PHP email is showing just like this. PHP 电子邮件就是这样显示的。

 $message = "<html><head></head><body>Hello</body></html>";
 $subject = "A New Quotation Recieved";
           $mail = new Mail();
            $mail->protocol = $this->config->get('config_mail_protocol');
            $mail->parameter = $this->config->get('config_mail_parameter');
            $mail->smtp_hostname = $this->config->get('config_mail_smtp_hostname');
            $mail->smtp_username = $this->config->get('config_mail_smtp_username');
            $mail->smtp_password = html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8');
            $mail->smtp_port = $this->config->get('config_mail_smtp_port');
            $mail->smtp_timeout = $this->config->get('config_mail_smtp_timeout');


            $mail->setTo('contact@mytrendin.com');
            $mail->setFrom($this->config->get('config_email'));
            $mail->setSender(html_entity_decode('Hello', ENT_QUOTES, 'UTF-8'));
            $mail->setSubject(html_entity_decode($subject, ENT_QUOTES, 'UTF-8'));
            $mail->setText($message);
            $mail->send();

Try to use this:尝试使用这个:

$mail->Body    = 'This is the HTML message body <b>in bold!</b>';
$mail->isHTML(true);                                  // Set email format to HTML

https://github.com/PHPMailer/PHPMailer - here you can also find some help. https://github.com/PHPMailer/PHPMailer - 在这里您还可以找到一些帮助。 Try "A simple example" part as it might be the most useful.尝试“一个简单的例子”部分,因为它可能是最有用的。

I happen to work for Elastic Email.我碰巧在 Elastic Email 工作。 Hope you will resolve your problems and have great fun using our product :).希望您能解决您的问题并在使用我们的产品时玩得开心:)。

https://github.com/ElasticEmail/ElasticEmail.WebApiClient-php - you could also try to use this. https://github.com/ElasticEmail/ElasticEmail.WebApiClient-php - 您也可以尝试使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM