1 (edited by pgregg 2004-05-17 20:53)

Topic: email (rfc) bug

Email headers should use \r\n instead of \n

Here is a patch to email.php to fix:

diff -r ./include/email.php ../../../../web/php.pgregg.com/forums/include/email.
php
74c74,76
<       $headers = 'From: '.$from."\n".'Date: '.date('r')."\n".'MIME-Version: 1.0'."\n".'Content-transfer-encoding: 8bit'."\n".'Content-type: text/plain; charset='.$lang_common['lang_encoding']."\n".'X-Mailer: PunBB Mailer';
---
>       $message = str_replace("\n", "\r\n", $message);
>       $crlf = chr(13).chr(10);
>       $headers = 'From: '.$from.$crlf.'Date: '.date('r').$crlf.'MIME-Version: 1.0'.$crlf.'Content-transfer-encoding: 8bit'.$crlf.'Content-type: text/plain; charset='.$lang_common['lang_encoding'].$crlf.'X-Mailer: PunBB Mailer';


Hope this helps.... Nice board (just d/l yesterday).

Oh (reason I found it) - Qmail MTA b0rks if you don't do it right.

Re: email (rfc) bug

It has been reported before and has been fixed in 1.2. Nice with a patch for people in need though. Thanks :)

From the changelog:

2004-02-22
""""""""""
*  Changed linebreaks from LF to CRLF in all outgoing e-mails (the RFC says so
   and a few SMTP servers require it).
"Programming is like sex: one mistake and you have to support it for the rest of your life."