Help - Search - Members - Calendar
Full Version: Problem to send email via PHP script
The Planet Forums > System Administration > Mail Hosting
1001studio
Hello,

there is an issue to send e-Mail from php sscript. all headers are correct (they worked on other server till few weeks ago)
When I try to send email (tipical is a form autoresponder) I receive mail from nobody@name.myserver.net instead of i.e. webmaster@mysite.com

Any ideas? I'm using CPanel so I look at WHM Tweaks Settings (Prevent the user 'nobody' from sending out mail to remote addresses ) and it's unchecked.

Thank you
Jacopo
patrick24601
What script or php command are you using? I have been using the php mail function without a problem for years now.
1001studio
Just php mail command

i.e.

$recipient.="".$Email."";
$headers.="From: Website <email@website.com>n";
$headers.="Return-Path: <email@website.com>n";
$headers.="X-Sender: <email@website.com>n";
$headers.="X-Mailer: PHPn";
$subject="SUBJECT";
$content.="CONTENTnn";
$content.="--rn";
$content.="SIGNATUREnn";
mail($recipient,$subject,$content,$headers);

I used it on other server in SM too without any problem.
I cannot understand why on this server it won't works....

Jacopo
dezignguy
You need to set the return path in the mail command...
CODE
mail($recipient,$subject,$content,$headers);


You'd use the 5th variable for that... so you just have to tack it on at the end of what you've got.
Fisherman
Mine is doing the same thing on several accounts. They have worked fine for a few years. I'm using nmsformail. It's the secure replacement for Matt's formmail.

It's not just formmail either. Sometimes it'll send me an e-mail from one of the accounts running the Agora shopping cart. The e-mail is sales and the e-mail says undelivered mail or failed or something like that and that there's no such e-mail as admin. In the first place, the cart is set up to send to sales and not admin. In the second place, there is an e-mail address named admin. I added it after getting the first one like that.

It's gotta be the server because all of these things have worked well for years.

Any ideas at all?
dezignguy
if you're using cpanel, then exim had some changes made to the mail handling rules a while back... it bounced undeliverable mail back to nobody or postmaster server-wide, instead of figuring out which domain name's main account it should be sent to, as it used to do.

Either fix your scripts to properly set the return path, or add the old exim rules back in. Search the cpanel forums for more info, at forums.cpanel.net
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.