php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17322 mail() fails (501 Syntax Error) under latest CVS
Submitted: 2002-05-20 19:05 UTC Modified: 2002-09-26 19:49 UTC
Votes:4
Avg. Score:4.0 ± 1.0
Reproduced:4 of 4 (100.0%)
Same Version:2 (50.0%)
Same OS:3 (75.0%)
From: chris at dvdplaza dot com dot au Assigned:
Status: No Feedback Package: Mail related
PHP Version: 4.0CVS-2002-05-20 OS: Windows 2000
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2002-05-20 19:05 UTC] chris at dvdplaza dot com dot au
Since upgrading to the CVS of PHP 4.3 (HAD to - bug #16626 was causing us chronic chaos and this was the only means to correct it) I am getting the following error each time a script tries to e-mail:

PHP Warning:  mail() SMTP server response: 501 Syntax Error in parameters or arguments in *SCRIPTNAME* on line xxx

PHP 4.3 is running as an Apache2 module on W2K, only additional module loaded is GZIP.  Never had any e-mail problems before (other than time stamps on PHP e-mails being incorrect, a long-time known bug).

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-05-20 19:09 UTC] mfischer@php.net
Finally! You're the first who uses the updated win32/mail() code it seems.

This error response you get seems really bogus. Can you try to cut down the *exakt* parameters you pass to the mail() function which causes this error?
 [2002-05-20 22:57 UTC] chris at dvdplaza dot com dot au
The simplest example would probably be the one below, since the addresses are all hardcoded (simply an auto-notification for myself) whereas all other mailings are obviously dynamic:

mail('form@dvdplaza.com.au', 'Invite Issued To ' . $PlazaUser[username], 'An invite was just produced for: ' . $PlazaUser[username], 'From: "DVD Plaza (Support)" <support@dvdplaza.com.au>');
 [2002-05-21 01:52 UTC] mfischer@php.net
Can you try instead of
From: "DVD
Plaza (Support)" <support@dvdplaza.com.au>

just

From: support@dvdplaza.com.au

?
 [2002-05-21 04:39 UTC] chris at dvdplaza dot com dot au
Forgot to mention that this error 9/10 causes the Apache 
child to exit and a new one to spawn and that occasionally 
an e-mail does get to its destination.

Now, I made the change you requested and no more errors are 
appearing in the error log - HOWEVER it isn't working as 
you'd expect.  Thus far out of around 30 or so refreshes 
I've only ended up with two e-mails plus the Apache child 
bombed out a couple of times and respawned.
 [2002-05-21 04:49 UTC] mfischer@php.net
First, the From: "DVD
Plaza (Support)" <support@dvdplaza.com.au> syntax isn't supported on win32 and never was. Only addresses in the simple form of foo@bar.com are supported.

Cay you try to revert to 4.2.1 and see if all emails get through at least ? But be aware that you need to use the ini setting "sendmail_from" in 4.2.1, From: in the header isn't support in this release.
 [2002-05-21 04:56 UTC] chris at dvdplaza dot com dot au
We've beeen using the mail command in that fashion without 
problem since 4.0.6???  This is the first time I've had to 
touch the mail commands?!?!?  It was working fine under 
4.2.1, problem only started the second I upgraded to php 
4.3.dev (which was purely for the cookie fix).
 [2002-05-21 05:18 UTC] chris at dvdplaza dot com dot au
We've beeen using the mail command in that fashion without 
problem since 4.0.6???  This is the first time I've had to 
touch the mail commands?!?!?  It was working fine under 
4.2.1, problem only started the second I upgraded to php 
4.3.dev (which was purely for the cookie fix).
 [2002-05-21 05:20 UTC] chris at dvdplaza dot com dot au
We've beeen using the mail command in that fashion without 
problem since 4.0.6???  This is the first time I've had to 
touch the mail commands?!?!?  It was working fine under 
4.2.1, problem only started the second I upgraded to php 
4.3.dev (which was purely for the cookie fix).
 [2002-05-21 05:22 UTC] chris at dvdplaza dot com dot au
Please delete duplicate posts, refreshed wrong window - 
SORRY :(
 [2002-05-21 06:50 UTC] chris at dvdplaza dot com dot au
Downgrade to PHP 4.2.1 mail works, upgrade back to PHP 
4.3.dev mail fails.  Reservedly restarted whole server, no 
change.
 [2002-05-21 18:40 UTC] chris at dvdplaza dot com dot au
Interesting, I downgraded to PHP 4.2.1 again since the mail 
failing is causing us a lot of grief (scripts randomly fail 
after this occurrs) and have discovered that the mail 
doesn't work properly there either!  That said when you 
initially restart Apache the mail does work for a short 
while, must be what caught me out when I tested it last 
night, and THEN it stops working.

The mail function being screwy in PHP 4.2.1 must have been 
a problem for us before, as a form that sends me e-mails 
has been generating hundreds less e-mails per day than I 
would have expected and I had formerly written it off as 
lack of interest (even though the Apache logs showed 
otherwise), so looks like it's not specific to PHP 4.3.dev 
but instead either PHP 4.2.1 or PHP 4.2.0 (don't have the 
time right at the moment to double check this).
 [2002-05-22 03:17 UTC] mfischer@php.net
The win32/mail() implementation suffers some inherent problems. I'll see what I can do, but being busy right now, this can take until next weekend. Assigning to me.
 [2002-05-22 08:33 UTC] chris at dvdplaza dot com dot au
Mail has been better throughout the day, certainly not 
perfect (lots of messages missing) but at least PHP 4.2.1 
is able to get SOME mail out as opposed to PHP 4.3.dev.  
Unfortunately by reverting back the cookie problem with 
4.2.x is again causing us hell :\

I've been doing some reading around and found that mail 
under Win32 with PHP has always been a little screwy - will 
be great to finally have that improved, to the benefit of 
all PHP users.  I appreciate your time is short and 
valuable,  I'll do whatever I can to make your efforts 
worthwhile (you into DVD?).
 [2002-05-22 21:12 UTC] chris at dvdplaza dot com dot au
BLOODY COMPUTERS!!!  PHP 4.2.1's mail handling is fine as I originally said, the reason I was missing mail yesterday was due to IE on my Mac not refreshing the pages I was constantly reloading.  Mail is flowing through just fine and refreshing one of my forms via my PC causes a mail every time.

So it's what I originally said - mail fails under PHP 4.3.dev but works under PHP 4.2.1.  Sorry for the confusion... argh!!!
 [2002-06-02 11:44 UTC] mfischer@php.net
I've gone through the code and I'm unable to reproduce the problem. What kind of MTA are you using?

Do you have another, simple example which used to work in < 4.3 ?
 [2002-06-02 19:14 UTC] chris at dvdplaza dot com dot au
What's an MTA?

We've since reverted again to PHP 4.2.1, and left it there (with a cookie workaround) as the mail issue was crippling a major promotion we are currently running.  We've had no further mail issues - so definitely specific to 4.3
 [2002-09-11 11:08 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php4-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-latest.zip


 [2002-09-26 19:49 UTC] sniper@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 [2003-01-29 10:26 UTC] f dot touchard at laposte dot net
Using :
- W2K Pro SP2
- Apache (version : Apache_1.3.27-win32-x86-no_src)
- PHP (version : php-4.3.0-Win32)
mail() works fine for me. I tested using different syntax :
"something" <name@domain.com> just doesn't work.
<name@domain.com> works (but < & > are not usfull at all), so just use :
name@domain.com

>[21 May 2002 4:49am] mfischer@php.net 
>First, the From: "DVD
>Plaza (Support)" <support@dvdplaza.com.au> syntax isn't >supported on
>win32 and never was. Only addresses in the simple form of >foo@bar.com
>are supported.

Here is a simple exemple that worked for me :
function send_mail($from_email, $to_email, $subject, $message) {
	$header = "MIME-Version: 1.0\r\n";
	$header .= "Content-Type: text/plain; charset=iso-8859-1\r\n";
	$header .= "From: ".$from_email."\r\n";
	$header .= "Reply-To : ".$from_email."\r\n";
	$header .= "Return-Path : ".$from_email."\r\n";
	$header .= "X-Priority: 1\r\n";
	$header .= "X-MSMail-Priority: High\r\n";
	$header .= "X-Mailer: PHP4\r\n";
	return(mail($to_email, $subject, $message, $header));
}
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 05:01:29 2024 UTC