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

空扰寡人 提交于 2019-12-06 03:33:24

问题


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

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

回答1:


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.




回答2:


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




回答3:


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




回答4:


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

Cleber.



来源:https://stackoverflow.com/questions/4627022/problem-sending-email-with-codeigniter-headers-sent-in-the-message-body

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!