You are here: mail(): carriage returns get scrambled « PHP Programming Language « IT news, forums, messages
mail(): carriage returns get scrambled

Posted by kAlvaro on 11/19/32 11:54

I wrote a custom class that uses mail() to send messages. My class
takes care that all lines end in \r\n as required by RFCs.

I have two Red Hat 9 servers (development + production). My development
server works fine; however, I've noticed that in my production server
extra line ending chars are added randomly to outgoing messages. I
didn't notice until now because Outlook handles it fine. On the
contrary, most other mail clients think these extra line feeds are
empty lines. As a result, headers pop into message body and message
body itself gets extra blanks line.

As I said, it looks random to me--I can't find any pattern:

Dear customer,\r\n
\r\n

.... turns into:

Dear customer,\n\n
\n\n

I looks like \r is replaced by \n... But:

Content-Type: text/plain; charset=iso-8859-1\r\n
Content-Transfer-Encoding: 8bit\r\n

.... turns into:

Content-Type: text/plain; charset=iso-8859-1\r\n
\r\n
Content-Transfer-Encoding: 8bit\n\n

(the same input \r\n gets two different outputs).

I check both body and custom headers just before calling mail():

echo str_replace(array("\n", "\r"), array("\\n\n", "\\r"), $headers);
echo str_replace(array("\n", "\r"), array("\\n\n", "\\r"), $body);
mai(.....);

At this point, everything's OK.

My first candidate was mod_security, yet disabling it makes no change.
We don't have a virus scanner. Mail server is postfix.

Do you have any hint??

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация