我一直在努力解决这个问题。无论我做什么,我都无法在使用 CodeIgniter (v 2.1.3) 生成的任何电子邮件消息中显示新行、空行或换行。
在我的控制器功能中:
$message = "Line one.\r\n\r\n" .
"Line two.\r\n\r\n" .
"Line three.\r\n\r\n";
$subject = "My Subject Line";
$this->load->library('email');
$config['newline'] = "\r\n"; // does not matter when I leave this out
$config['crlf'] = "\r\n"; // does not matter when I leave this out
$this->email->initialize($config);
$this->email->from('system@mydomain.com', 'my system');
$this->email->to('me@gmail.com');
$this->email->subject($subject);
$this->email->message($message);
$this->email->send();
echo $this->email->print_debugger();
除了上面显示的内容外,我没有更改任何设置或默认值。
消息的“来源”看起来就像这个print_debugger()
输出......
User-Agent: CodeIgniter
Date: Sun, 24 Mar 2013 17:46:47 -0400
From: "my system"
Return-Path:
Reply-To: "system@mydomain.com"
X-Sender: system@mydomain.com
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <xxxxxx@mydomain.com>
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="B_ALT_514f74472bd26"
=?utf-8?Q?My_Subject_Line?=
This is a multi-part message in MIME format.
Your email application may not support this format.
--B_ALT_514f74472bd26
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Line one.
Line two.
Line three.
--B_ALT_514f74472bd26
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Line one.
Line two.
Line three.
--B_ALT_514f74472bd26--
但是,问题在于实际消息在所有电子邮件客户端中呈现如下。
Line one.Line two.Line three.
为什么我"\r\n"
的被忽视?
这是一条非常简单的消息,我宁愿不必使用任何html
选项。 根据 CI 文档,mailtype
首选项应默认为text
.
我在哪里错了?