使用 Codeigniter 发送电子邮件时出现问题 - 在邮件正文中发送标头

发布于 2024-10-11 01:38:50 字数 2272 浏览 12 评论 0原文

Codeigniter 中的电子邮件类出现一个奇怪的问题。当我直接向我的 Gmail 帐户电子邮件地址发送电子邮件时,效果很好。但是,如果我将电子邮件发送到不同的电子邮件地址并使用 POP3 将该电子邮件地址导入到 gmail 中,则由于某种原因,所有标头都会包含在邮件中。

以下是发送电子邮件的代码:

$this->email->clear();
$config['mailtype'] = "html";
$this->email->initialize($config);
$this->email->set_newline("\r\n");
$this->email->from('[email protected]', 'Website');
$this->email->to('[email protected]');
$this->email->message($message);

以下是当电子邮件发送到通过 POP3 导入 Gmail 的帐户时到达我的收件箱的内容:

Date: Fri, 7 Jan 2011 15:07:04 +0000

From: "Website" <[email protected]>
Reply-To: "[email protected]" <[email protected]>
X-Sender: [email protected]

X-Mailer: CodeIgniter

X-Priority: 3 (Normal)

Message-ID: <[email protected]>

Mime-Version: 1.0

Content-Type: multipart/alternative; boundary="B_ALT_4d272c1835c46"




This is a multi-part message in MIME format.

Your email application may not support this format.



--B_ALT_4d272c1835c46

Content-Type: text/plain; charset=utf-8

Content-Transfer-Encoding: 8bit



this is the email message content





--B_ALT_4d272c1835c46

Content-Type: text/html; charset=utf-8

Content-Transfer-Encoding: quoted-printable

<html>
<body>
       <p>this is the email message content
</p>
</body>
</html>



--B_ALT_4d272c1835c46--

Having a strange issue with the email class in codeigniter. When I send email directly to my gmail account email address, it works fine. However if I send email to a different email address and use POP3 to import that email address into gmail, then for some reason all the headers are included in the message.

Here's the code for sending the email:

$this->email->clear();
$config['mailtype'] = "html";
$this->email->initialize($config);
$this->email->set_newline("\r\n");
$this->email->from('[email protected]', 'Website');
$this->email->to('[email protected]');
$this->email->message($message);

Here's what arrives in my inbox when the email is sent to an account which is imported into gmail via POP3:

Date: Fri, 7 Jan 2011 15:07:04 +0000

From: "Website" <[email protected]>
Reply-To: "[email protected]" <[email protected]>
X-Sender: [email protected]

X-Mailer: CodeIgniter

X-Priority: 3 (Normal)

Message-ID: <[email protected]>

Mime-Version: 1.0

Content-Type: multipart/alternative; boundary="B_ALT_4d272c1835c46"




This is a multi-part message in MIME format.

Your email application may not support this format.



--B_ALT_4d272c1835c46

Content-Type: text/plain; charset=utf-8

Content-Transfer-Encoding: 8bit



this is the email message content





--B_ALT_4d272c1835c46

Content-Type: text/html; charset=utf-8

Content-Transfer-Encoding: quoted-printable

<html>
<body>
       <p>this is the email message content
</p>
</body>
</html>



--B_ALT_4d272c1835c46--

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

瑕疵 2024-10-18 01:38:50

这听起来好像不是 codeigniter 的问题。

您已经测试并表明消息发送正确。您已经看到它发送到另一个 POP3 帐户。 GMail 能够获取 POP3 帐户数据,但会混淆它。

下一个测试是使用客户端,例如 Thunderbird(桌面)或 Squirrel Mail(Web),并查看邮件是否从这些来源正确到达您的手中。

下一个测试(如果不是)是在另一台服务器上使用另一个提供商完全不同的 POP3 帐户,看看会发生什么。

原因是故障(如您所见)似乎发生在 POP3 投递和 GMail 到达之间。作为故障查找者,我想要确定这是否是一封格式错误的电子邮件,或者(这是我的猜测)POP3 服务器是否有任何 CI 可能没有考虑到的异常配置。

为了节省时间,我会在 CodeIgniter 论坛上发帖询问是否有其他人遇到过这些问题,在这种情况下,可能存在某种已知的错误或故障或缺点。在等待答案时,我会查看我的 POP3 服务器并询问它为什么以我不喜欢的方式中继消息,以及这是否是 POP3、服务器类型或配置问题。最重要的是,一旦我知道问题是什么,我如何更改我的电子邮件发送软件(CI)以发送不会以这种方式中断的电子邮件?

但首先需要了解问题的根本原因。

This sounds like it is not a codeigniter problem.

You have tested and shown that the message sends correctly. You have seen that it sends to the other POP3 account. GMail is able to go get the POP3 account data but is garbeling it up.

The next test is to use a client, say, Thunderbird (desktop) or Squirrel Mail (web) and see if the mail is arriving correctly to you from these sources.

The next test (if it is not) is to use an entirely different POP3 account with another provider on another server and see what happens there.

The reason for this is that the fault (as you are seeing it) appears to be happening between deliver on the POP3 and arrival at GMail. What I would want as a fault finder is to establish if this is a badly formed email or (and this would be my guess) if the POP3 server has any unusual configuration that CI is maybe not taking into account.

To save time I would post on the CodeIgniter forums to ask if anyone else has experienced these issues in which case there maybe a known bug or fault or shortcoming of some kind. While waiting for an answer I would be looking at my POP3 server and asking it why it is relaying the messages in a way that I do not like and if this is POP3, the server type or a configuration issue. Most importantly once I know what the problem is how can I change my email sending software (CI) to send emails that do not break in this way?

But first knowing the problem's root cause is needed.

恋竹姑娘 2024-10-18 01:38:50

请使用
$config['协议'] = 'sendmail';

Please use
$config['protocol'] = 'sendmail';

纸短情长 2024-10-18 01:38:50

由于邮件被发送到有问题的地址(pop3 帐户)codeigniter/sendmail/php/dns/smtp,并且所有参与邮件发送的人员都完成了对他们的期望。此外,您还证明 Google 的 Mail Fetcher 已配置,并且可以成功从 pop3 服务器获取邮件并将其放入您的收件箱,也没有任何问题。

您想知道的是如何更改从 pop3 消息导入的这些消息在您的 Gmail 帐户收件箱中的显示方式,这远远超出了您在此定位的受众范围,如果您的消息已送达,我们的工作就完成了。

也许解决问题的一种方法是将邮件直接发送到您的 Gmail 帐户。作为主要收件人(发送至,您可以用逗号分隔多个帐户)或抄送或密件抄送地址之一,这将避免从 POP3 获取的需要。然后,该消息将按照发送给您的任何其他消息显示在您的收件箱中,并且标头照常隐藏。

这对我有用。

让我们知道事情的结果...

Since the mail gets delivered to the address in question (the pop3 account) codeigniter/sendmail/php/dns/smtp and all those involved in the mail delivery has done what was expected of them. In addition you have also proven that Google's Mail Fetcher is configured and can successfully fetch mail from the pop3 server and place it in your inbox, nothing wrong there either.

What you want to know is how to change the way these imported from pop3 messages are displayed in your gmail account inbox, which falls way outside the scope of the audience you are targeting here, if your message is delivered our job is done.

One way to solve the problem perhaps, is to send the mail directly to your gmail account instead. As the primary recipient (send to, you may comma separate multiple accounts) or either one of CC or BCC addresses, which will avoid the need to fetch from POP3. This will then be displayed in your inbox as per any other message sent to you with the headers hidden as per usual.

This works for me.

Let us know how things turn out...

叫嚣ゝ 2024-10-18 01:38:50

我相信这篇文章可以帮助您:使用 CodeIgniter 发送电子邮件克莱伯

I believe this post can help you: Sending E-mails with CodeIgniter

Cleber.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文