PHPMailer Bug: Headers showing in message body

July 1st, 2009

PHPMailer is a handy little class which smoothes out the minefiled that is sending email with PHP. Okay, it’s not exactly difficult, but it’s not always striaghtforward either.

I did come across a niggly little bug in the latest release (2.3 at time of writing) which causes a large number of mail clients to incorrectly parse the generated email headers. The most obvious manifestation of this bug is that the headers are displayed in the body. Which probably isn’t what you want.

Fortunately the ‘fix’ is simple. By default PHPMailer 2.3 defaults to using “\r\n” for linebreaks. This is what confuses a lot of mail clients as they’re expecting a “\n”.

PHPMailer Class, line 259:

change:

var $LE = "\r\n";

to:

var $LE = "\n";

That worked for me, although your mileage may vary.

Posted in Web | Tagged with:

5 Responses

  1. RickNunn

    FIRST!

  2. Nick

    Dude, I can’t see any difference between the two lines of code?

  3. Jamie Thompson

    oops. fixed!

  4. Fuzzy Orange

    Tits or GTFO!

  5. aldo

    thanks man, you saved me

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.