Form handling code stopped working due to PHP upgrade

Our hosting company recently upgraded to version 4 and my php code stopped processing the email that is generated from a forms page.

The error I get is:
Warning: mail() [function.mail]: SMTP server response: 501 unacceptable mail address in D:Inetpubcceca.netread1test.php on line 27

That line reads:
mail ($mailto, $subject, $body, $mailfrom);

If you need more info to make an assesment, please let me know.

Thanks for any help!

I suppose it would help to see the the values of $mailto, $subject, $body and $mailform from a message that gives you that error.

Here’s all that line 27 looks at:

$mailfrom = “From:{$HTTP_POST_VARS[‘AcctName’]}”;
$subject= “Meter Readings”;
$body = “* * * * * BEGIN FEEDBACK * * * * nn$number.nnnAccount Name: {$HTTP_POST_VARS[‘AcctName’]}.nAccount#: {$HTTP_POST_VARS[‘AcctNumber’]}.nMeter Reading: {$HTTP_POST_VARS[‘Reading’]}.nDate of Reading: {$HTTP_POST_VARS[‘ReadingDate’]}.nEmail Address: {$HTTP_POST_VARS[‘Email’]}.
* * * * END FEEDBACK * * * * *”;

mail ($mailto, $subject, $body, $mailfrom);

Like I say, please let me know if you need anything else. Thank you!

I am not sure why the { and } are surrounding the globals. I don’t know if that would impact it or not. (Again I have never used them in that way. It may be correct)

Also what is the value of mailto? AND actual value from the other variables. (Not just how they are initialized.)

If you could echo out the variables (before the MAIL() function) and post them, that might help.

Sorry, I should have included everything huh :wink:

$title = "Submit your Meter Readings";
$home = "";
$mailto = "[email protected]";
$number = "Information Submitted From IP $_SERVER[REMOTE_ADDR]";

PRINT "<html><head><title>Thank you</title></head><body><div align="left"><table border="0" cellpadding="2" cellspacing="0" width="100%"><tr><td width="100%" height="50"></td></tr><tr><td width="100%" valign="top" align="left"><p align="center"><font face="Arial" size="3">Your message has been sent.<BR><b>Thank you {$HTTP_POST_VARS['AcctName']}, for sending your meter readings.</b><br> $number and has been logged.</font></p><p align="center"><font face="Arial" size="4"><a href="$home">Back To </a></font></p></td></tr><tr><td width="100%" height="20"></td></tr></table></div></body></html>";

$mailfrom = "From:{$HTTP_POST_VARS['AcctName']}";
$subject= "Meter Readings";
$body = "* * * * * BEGIN FEEDBACK * * * * *nn$number.nnnAccount Name:  {$HTTP_POST_VARS['AcctName']}.nAccount#: {$HTTP_POST_VARS['AcctNumber']}.nMeter Reading: {$HTTP_POST_VARS['Reading']}.nDate of Reading: {$HTTP_POST_VARS['ReadingDate']}.nEmail Address: {$HTTP_POST_VARS['Email']}.
nn* * * * * END FEEDBACK * * * * *";

mail ($mailto, $subject, $body, $mailfrom);

Like I say, this code has worked for 2-3 years now and since they upgraded, it stopped processing. I’m lost!


Again, I am concerned about the { and } around the HTTP_POST_VARS in the various locations. Additionally, it’s my understanding that using the posted Vars in that way can create security risks (although I am not sure what they are).

I would recommend that it’s time for you to upgrade as well to the$_POST method.

$title = “Submit your Meter Readings”;
$home = “”;
$mailto = "[email protected]";
$number = “Information Submitted From IP $_SERVER[REMOTE_ADDR]”;

PRINT "Thank you

Your message has been sent.
Thank you “.$_POST[‘AcctName’].”, for sending your meter readings.
$number and has been logged.

Back To


$mailfrom = “From:”.$_POST[‘AcctName’]. ;
$subject= “Meter Readings”;
$body = “* * * * * BEGIN FEEDBACK * * * * nn$number.nnnAccount Name: “.$_POST[‘AcctName’].”.nAccount#: “.$_POST[‘AcctNumber’].”.nMeter Reading: “.$_POST[‘Reading’].”.nDate of Reading: “.$_POST[‘ReadingDate’].”.nEmail Address: “.$_POST[‘Email’].”.
* * * * END FEEDBACK * * * * *”;

mail ($mailto, $subject, $body, $mailfrom);

OK, I’ll give that a try and post back. Thanks so much!!!

OK, no error messages after I had to remove “;” due to a parse error…but, it’s not sending the email.


u should never have to remove a ‘;’ because of an error.

are u taking about this line?
[php]$mailfrom = “From:”.$_POST[‘AcctName’]. ;[/php]

the ‘;’ is OK, u have to remove the ‘.’

yes, I was talking about that line. I removed the “;” because the Parse error message said it was unexpected. I’ll put it back and remove the “.” and try it. I’ll post back. Thanks again!

Sorry about that. I had done a find and replace and ended up with the .""; and I got rid of the “” not thinking about the ’ . ’

No problem Peg…I appreciate any help!

Update: I put the “;” back and got rid of the “.”, and the error message is still gone, but no email is being sent/received.

Can we now look at the email function part of it and make sure that’s correct? I can’t imagine why that would have changed with an update…but I only dabble in PHP, so I don’t know.

Thanks again!

i can’t find any other errors. maybe it’s the mailserver malefunctioning.

do u have access to the error log’s?

if not i would contact the provider, telling him the prob, and giving him the exact time of one of the testmails. then it should be easy for them to check their logs for errors.

Also since this is on a windows system, they may need to “Adjust” the php.ini since windows systems don’t (by default) have a mail server that is accessed quite like a *Nix system does.

i guess i found it:
“501 unacceptable mail address”
$mailfrom = “From:”.$_POST[‘AcctName’];
ur passing the Name as email address.

try using
[php]$mailfrom = "From: ".$_POST[‘Email’];[/php]

[php]$mailfrom = ‘From: "’.$_POST[‘AcctName’].’" <’.$_POST[‘Email’].’>’;[/php]

i guess they updated the SMTP-server as well, and the old one just wasn’t complaynig about that error.

Q1712: I tried both and they were error free, but the mail did not send.

Let me tell something that might have a bearing on it…not sure.

We have this hosting service that originally had a mail server with the package. About a year and a half ago, I wanted to run our own mail server, so we had them disable the mail part of our package. This was disabled way before this script stopped working. But if this new version 4 that they upgraded to somehow doesn’t mail in the same way, maybe our current arrangements are not going to work(?).


same error?

Q1712: No, error free = no error at all. It just isn’t generating the email that supposed to send.

I’m still lost. :(

sry that was a dum question! i still was remembering the error from the beginning:

and havnt read ur post very well.

have u tryed to contact the provider/checked the loggs?

Okay, I got with our hosting company and explained everything to them and even sent the script to them. This is what they responded:

When sending email from code, use as your mail server.

If you have any further questions, please contact us

Seems vague to me! :-?

Sponsor our Newsletter | Privacy Policy | Terms of Service