Help - Search - Members - Calendar
Full Version: Email From:
The Planet Forums > Control Panels > cPanel/WHM
funksta
Hi all,

I have had a script on a one of the sites on my server for sometime, it basically takes the results from the form, stores it in a database and emails the results back to the user. This today has not stopped working but now works differently. It does everything it should except it now says username@host.domain.com.

The script is PHP and is:

[PHP]mail($OWNER_EMAIL, $subject, $message, "FROM: $RESPONSENAME<$RESPONSEFROM>") || DIE("Not able to send email.");[/PHP]

So when a user receives a submission, in their mail client it should say it's from Site Registrations and not the servers hostname. I have tried various different ways of doing this in php but it is still the same. I have phpsuexex and suexec installed.

Anyone any ideas?
funksta
Does anyone have an answer to this, I know it may seem like a php problem but I think it is most likely to do with phpsuexec as the syntax is correct.

Thanks
Liam
shacker
You (or your customers) need to add the optional -f flag to the PHP mail call to avoid this. I got so tired of receiving bounces from my customers' scripts that I finally added this as a customer FAQ:

Sending Mail from PHP

When using the PHP mail() function, please use the optional "-f" flag to ensure that the messages your applications generate have a Return-Path: header line appropriate to your account -- otherwise your messages may appear to originate from Birdhouse rather than from you.

A standard PHP mail() call looks like this:

mail($recipient_address, "$subject_line", "$message_body", "From: $from_address");

Please use this format instead:

mail($recipient_address, "$subject_line", "$message_body", "From: $from_address", "-fbounce@yourdomain.com");

Notice the last parameter -- the bounce address is NOT separated from the "-f" by any space. Doing this ensures that if the mail goes to a bad recipient address, the bounce will return to you, not to Birdhouse. You can of course use any address you like for the bounce address.
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-2009 Invision Power Services, Inc.