I am currently developing a website with the help of codeigniter and the ion auth library.
I am trying to use ion auth's standard functionality to reset a users password.
In the library there are 2 functions:
forgotten_password($identity)
forgotten_password_complete($code)
Both functions (in case validation goes through) send an email to the user. The functions themselves work, but the emails i receive are broken. The emails header is displayed as a part of the emails body. This is how a broken email looks:
Date: Fri, 18 Nov 2011 23:36:32 +0100
From: "Example.com" <admin@example.com>
Reply-To: "admin@example.com" <admin@example.com>
X-Sender: admin@example.com
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <4ec6ddf0d26a3@example.com>
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="B_ALT_4ec6ddf0d26b9"
This is a multi-part message in MIME format.
Your email application may not support this format.
--B_ALT_4ec6ddf0d26b9
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
New Password for test_user
Your password has been reset to: 0774b65f5e
--B_ALT_4ec6ddf0d26b9
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
<html>
<body>
<h1>New Password for test_user</h1>
=09
<p>Your password has been reset to: 0774b65f5e</p>
</body>
</html>
--B_ALT_4ec6ddf0d26b9--
However I was able to track down the line which is causing the trouble:
$this->ci->email->set_newline("\r\n");
When I comment out this line (in both functions mentioned above), the emails I receive when I reset a users password are fine.
Can someone explain to me the purpose of this line and wether or not it is a good idea to solve this problem by just commenting the line out.
I also found 2 questions
- Problem sending email with Codeigniter - Headers sent in the message body
- https://stackoverflow.com/questions/6740672/mime-format-email-breaking-sporadically-in-hotmail-php-codeigniter
referring to the same or at least a similar problem. As they are fairly old and haven't been answered yet, I created a new one. Hope no one minds.