Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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--
like image 697
Brian Avatar asked Nov 14 '22 04:11

Brian


1 Answers

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.

like image 186
Matthew Brown aka Lord Matt Avatar answered Dec 18 '22 17:12

Matthew Brown aka Lord Matt