Php 带有SMTP的Codeigniter电子邮件显示奇怪的格式
我有一个HTML消息如下Php 带有SMTP的Codeigniter电子邮件显示奇怪的格式,php,email,smtp,phpmailer,codeigniter-3,Php,Email,Smtp,Phpmailer,Codeigniter 3,我有一个HTML消息如下 <p>This is a bank account number *********0205</p> <p><b>This is a test email.</b></p> <p>This is my email me@me.com</p> <p>This is a link <a href='https://xxxxxx.uslogistics.com/i
<p>This is a bank account number *********0205</p>
<p><b>This is a test email.</b></p>
<p>This is my email me@me.com</p>
<p>This is a link <a href='https://xxxxxx.uslogistics.com/images/logo_big.png'>https://xxxxxx.uslogistics.com/images/logo_big.png</a><p>
这是一个银行账号************0205
这是一封测试邮件
这是我的电子邮件me@me.com
这是一个链接
我想通过SMTP发送该邮件。使用的主机是smtp.office365.com
我使用的是Codeignitor,当我在没有SMTP的情况下发送电子邮件时,收到的电子邮件显示良好,请参见下面的(图像和代码)
您是否尝试过在PHP var中保存您的正文,然后将其分配到CI或PHPMailer中的$mail->body
中?如果您是指在PHPMailer中,我刚刚执行了此操作,但它仍能正确显示电子邮件。看起来像是CI的邮件程序中的错误。那些=
字符表示它使用的是引用的可打印传输编码,但是如果它弄乱了编码的其他方面,它可能会留下这样的工件。您是否使用最新的CI?是最新版本3.1.7
<?php
$this->load->library('email');
$body = "<p><b>This is a test email.</b></p><p>This is my email me@me.com</p><p>This is a link <a href='https://xxxxxx.uslogistics.com/images/logo_big.png'>https://xxxxxx.uslogistics.com/images/logo_big.png</a><p>";
$config['mailtype'] = 'html';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;
$config['newline'] = "\r\n";
$this->email->clear(TRUE);
$this->email->initialize($config);
$this->email->from("no-reply@domain.com", "No Replay");
$this->email->to("myownemail@hotmail.fr");
$this->email->subject("Test");
$this->email->message($body);
$this->email->send();
$this->load->library('email');
$body = "<p><b>This is a test email.</b></p><p>This is my email me@me.com</p><p>This is a link <a href='https://xxxxxx.uslogistics.com/images/logo_big.png'>https://xxxxxx.uslogistics.com/images/logo_big.png</a><p>";
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'smtp.office365.com';
$config['smtp_user'] = ""; //Here I put the SMTP username
$config['smtp_pass'] =""; //Here I put the SMTP password
$config['smtp_port'] = '587';
$config['smtp_crypto'] = 'tls';
$config['mailtype'] = 'html';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;
$config['newline'] = "\r\n";
$this->email->clear(TRUE);
$this->email->initialize($config);
$this->email->from("", "No Replay");//Here I put the SMTP username as email.
$this->email->to("myownemail@hotmail.fr");
$this->email->subject("Test");
$this->email->message($body);
$this->email->send();
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'vendor/autoload.php';
$mail = new PHPMailer(true);
try {
$mail->SMTPDebug = 2;
$mail->isSMTP();
$mail->Host = 'smtp.office365.com';
$mail->SMTPAuth = true;
$mail->Username = '';//Here I put the SMTP username.
$mail->Password = '';//Here I put the SMTP password.
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$mail->setFrom('');//Here I put the SMTP username as email.
$mail->addAddress('myownemail@hotmail.fr');
$mail->isHTML(true);
$mail->Subject = '';
$mail->Body = "<p><b>This is a test email.</b></p><p>This is my email me@me.com</p><p>This is a link <a href='https://xxxxxx.uslogistics.com/images/logo_big.png'>https://xxxxxx.uslogistics.com/images/logo_big.png</a><p>";
$mail->send();
echo 'Message has been sent';
} catch (Exception $e) {
echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
}