php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #620 mail() not RFC821/822 compliant (1/4)
Submitted: 1998-08-06 00:29 UTC Modified: 1998-08-13 15:54 UTC
From: walton at nordicdms dot com Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 3.0.2a OS: Win32
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: walton at nordicdms dot com
New email:
PHP Version: OS:

 

 [1998-08-06 00:29 UTC] walton at nordicdms dot com
I ran into problems using PHP mail() on Win32 with qmail.
As it turns out, the problems were caused by non-compliance
with RFCs in sendmail.c.  Thus, this series of bug reports.

<CRLF> line endings
-------------------
RFC822 Appendix D:
  message =  fields *( CRLF *text )
    ; Everything after
    ;  first null line
    ;  is message body
  field   =  field-name ":" [ field-body ] CRLF
  text    =  <any CHAR, including bare ; => atoms, specials,
             CR & bare LF, but NOT     ;  comments and
             including CRLF>           ;  quoted-strings are
                                       ;  NOT recognized.
RFC821 4.1.1:
  The mail data is terminated by a line containing only a
  period, that is the character sequence "<CRLF>.<CRLF>" 


Here are diffs that should allow mail() to work with qmail.
(I also moved Subject: before To:, per RFC recommendation,
and changed SNMP -> SMTP.)

sendmail.h
----------
> diff sendmail.h newsendmail.h
20c20
< #define	SNMP_SERVER_ERROR 9
---
> #define	SMTP_SERVER_ERROR 9

sendmail.c
----------
> diff sendmail.c newsendmail.c
289c289
< 	if ((res = Post("\n.\n")) != SUCCESS)
---
> 	if ((res = Post("\r\n.\r\n")) != SUCCESS)
327c327
< 	p += sprintf(p, "Date: %s, %02d %s %04d %02d:%02d:%02d %s%02d%02d\n",
---
> 	p += sprintf(p, "Date: %s, %02d %s %04d %02d:%02d:%02d %s%02d%02d\r\n",
340c340
< 		p += sprintf(p, "From: %s\n", RPath);
---
> 		p += sprintf(p, "From: %s\r\n", RPath);
342,343c342,343
< 	p += sprintf(p, "To: %s\n", mailTo);
< 	p += sprintf(p, "Subject: %s\n", Subject);
---
> 	p += sprintf(p, "Subject: %s\r\n", Subject);
> 	p += sprintf(p, "To: %s\r\n", mailTo);
345c345
< 		p += sprintf(p, "%s\n", xheaders);
---
> 		p += sprintf(p, "%s\r\n", xheaders);
351c351
< 	if ((res = Post("\n")) != SUCCESS)
---
> 	if ((res = Post("\r\n")) != SUCCESS)
470c470
< 		return (SNMP_SERVER_ERROR);
---
> 		return (SMTP_SERVER_ERROR);


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1998-08-13 15:54 UTC] shane
Patch has been applied.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Mon Jun 15 01:00:02 2026 UTC