简体   繁体   English

使用Codeigniter发送电子邮件时遇到问题 - 邮件正文中发送的邮件头

[英]Problem sending email with Codeigniter - Headers sent in the message body

Having a strange issue with the email class in codeigniter. 在codeigniter中的电子邮件类有一个奇怪的问题。 When I send email directly to my gmail account email address, it works fine. 当我直接向我的Gmail帐户电子邮件地址发送电子邮件时,它可以正常工作。 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. 但是,如果我将电子邮件发送到其他电子邮件地址并使用POP3将该电子邮件地址导入gmail,则由于某种原因,所有标头都包含在邮件中。

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@example.com', 'Website');
$this->email->to('accountthatimportstogmail@url.com');
$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: 当电子邮件发送到通过POP3导入gmail的帐户时,这是收件箱中的内容:

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

From: "Website" <email@example.com>
Reply-To: "email@example.com" <email@example.com>
X-Sender: email@example.com

X-Mailer: CodeIgniter

X-Priority: 3 (Normal)

Message-ID: <4d272c1835479@example.com>

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--

This sounds like it is not a codeigniter problem. 这听起来好像不是一个codeigniter问题。

You have tested and shown that the message sends correctly. 您已经测试并显示消息正确发送。 You have seen that it sends to the other POP3 account. 您已经看到它发送到其他POP3帐户。 GMail is able to go get the POP3 account data but is garbeling it up. GMail能够获得POP3帐户数据,但却能够获得它。

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. 下一个测试是使用客户端,比如Thunderbird(桌面)或Squirrel Mail(web),看看邮件是否从这些来源正确到达您。

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. 下一个测试(如果不是)是在另一台服务器上使用与另一个提供商完全不同的POP3帐户,看看那里发生了什么。

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. 这样做的原因是错误(正如你所看到的)似乎发生在POP3的交付和到达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. 我想要的故障查找器是确定这是一个格式错误的电子邮件或(这将是我的猜测)如果POP3服务器有任何异常配置,CI可能没有考虑到。

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

But first knowing the problem's root cause is needed. 但首先需要了解问题的根本原因。

请使用$ config ['protocol'] ='sendmail';

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. 由于邮件被传递到相关地址(pop3帐户)codeigniter / sendmail / php / dns / smtp,所有参与邮件传递的人都已经完成了对他们的期望。 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. 此外,您还证明了Google的邮件提取程序已经配置,可以从pop3服务器成功获取邮件并将其放入收件箱,也没有任何问题。

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. 您想知道的是如何更改从您的Gmail帐户收件箱中显示的pop3邮件导入方式,如果您的邮件已完成,我们的工作已完成,这超出了您定位的受众范围。

One way to solve the problem perhaps, is to send the mail directly to your gmail account instead. 解决问题的一种方法是将邮件直接发送到您的Gmail帐户。 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. 作为主要收件人(发送给您,您可以逗号分隔多个帐户)或CC或BCC地址中的任何一个,这将避免从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... 让我们知道事情的结果......

I believe this post can help you: Sending E-mails with CodeIgniter 我相信这篇文章可以帮助您: 使用CodeIgniter发送电子邮件

Cleber. 克莱伯。

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

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