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

时间:2019-01-03 14:32:59

标签: php email

为什么HTML电子邮件只是在php电子邮件中显示代码。我正在尝试使用elasticemail通过php发送电子邮件,但显示的只是代码。我发现应该在此处添加标题的地方。但问题是我无法理解如何添加此代码。

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

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();

1 个答案:

答案 0 :(得分:0)

尝试使用此功能:

country

https://github.com/PHPMailer/PHPMailer-在这里您还可以找到一些帮助。尝试“简单示例”部分,因为它可能是最有用的。

我碰巧在Elastic Email工作。希望您能解决您的问题,并使用我们的产品带来很多乐趣:)。

https://github.com/ElasticEmail/ElasticEmail.WebApiClient-php-您也可以尝试使用它。