ID:               15841
 Comment by:       guy dot kastenbaum at filnet dot net
 Reported By:      rha at juggernaut dot com dot au
 Status:           No Feedback
 Bug Type:         Mail related
 Operating System: Linux
 PHP Version:      4.1.2
 Assigned To:      yohgaki
 New Comment:

I agree with @patpro, mail() should reformate the headers.

This is my quick-and-dirty workaround (from a Q&D specialist) , in
/etc/php.ini :

sendmail_path = "unix2dos|dos2unix|sendmail -t -i"


Guyzmo -- (don't let me programm after midnight)


Previous Comments:
------------------------------------------------------------------------

[2004-09-28 00:41:06] zap at cyborganic dot net

I suddenly had header problems. Perhaps my host changed mail configs or
updated PHP (they never reply to my email, so I don't ask many
question). In any case, all my beautiful HTML emails were being sent
out with broken headers that yturned them into ugly unreadable text and
code.

I am on a Unix server, so I changed all my /r/n newlines to /n. This
fixed the issue immediately. If you find this happens to you, just use
the appropriate newline characters for your host OS.

THANKS for pointing out this bug!

------------------------------------------------------------------------

[2004-06-09 09:25:00] patpro at patpro dot net

Hi,

I would really want official PHP Team confirmation for 
comments [18 Apr 2:46pm CEST] and [6 Mar 2002 11:04am 
CET].
I'm facing the same problem on FreeBSD 5.x, mod_php4
-4.3.6_1,1
If you follow the documentation (using \r\n) mail() will 
output badly formated headers. Many SMTPds or Filters 
will rewrite headers (sendmail does, Amavisd-new does, 
..., but postfix alone doesn't, for example)

I've set up a shell script to pipe mail()'s output into 
a file rather than into a SMTP : 

  $ more /usr/local/sbin/sendmail.cat 
  #!/bin/sh
  cat > /tmp/mailout

then I've set sendmail path to /usr/local/sbin/
sendmail.cat in httpd.conf : 

  php_admin_value sendmail_path "/usr/local/sbin/
sendmail.cat"

using \r\n as a header separator results in a mix of \n 
and \r\n :

  $ cat -v /tmp/mailout
  To: [EMAIL PROTECTED]
  Subject: un dernier test
  From: [EMAIL PROTECTED]
  Reply-To: [EMAIL PROTECTED]
  Content-Type: text/html; charset=iso-8859-1^M
  MIME-Version: 1.0^M
  Content-Transfer-Encoding: 8bit^M

this mix is not RFC compliant and breaks rendering in 
many mail clients.

It would be nice to change the php documentation 
accordingly, and even nicer to provide mail() with the 
ability to reformat headers.

------------------------------------------------------------------------

[2004-04-18 14:46:32] phpbug at labres dot at

Documentation of mail() states:

"Note:  You must use \r\n to separate headers, although some Unix mail
transfer agents may work with just a single newline (\n)."

This is WRONG. On Unix systems, any line ending (also between header
fields) has to be \n. On Windows Systems, it has to be \r\n.

Here is part of the sounce code in mail.c (in case of a Unix system):
        sendmail = popen(sendmail_cmd, "w");
        fprintf(sendmail, "To: %s\n", to);
        fprintf(sendmail, "Subject: %s\n", subject);
        if (headers != NULL) {
                fprintf(sendmail, "%s\n", headers);
        }
        fprintf(sendmail, "\n%s\n", message);
        ret = pclose(sendmail);

On Windows Systems, the SMTP session is handled within SendText() in
sendmail.c, which sends headers and message as is, so the line endings
have to be \r\n.

Please correct the above cited note and any samples.

There is a further bug in example 4:
| $headers .= "Bcc: [EMAIL PROTECTED]";
     remove the ending line break

The header must not end with a line break. As you can see in above code
snipet, the mail implementation adds a \n at the end of the header.

BTW, this is a documentation problem.

------------------------------------------------------------------------

[2002-06-26 01:00:07] php-bugs at lists dot php dot net

No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".

------------------------------------------------------------------------

[2002-05-25 21:43:58] [EMAIL PROTECTED]

mail() is NOT the all-in-one solution, nor is it really platform
compatible. In fact, win32/mail() is a completely different kind of
story (using native socket interface to talk to sendmail daemon on port
25) then on unix (calling another executeable and exchanging data)

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/15841

-- 
Edit this bug report at http://bugs.php.net/?id=15841&edit=1

Reply via email to