Forum Moderators: coopster
My problem is that I use the PHP mail function to send out a confirmation email for new users - PHP sends it out apparently as nobody.
Any suggetsions on a quick fix to sort this out asap? -- at the moment I have to manually send out the emails from my home pc, which is a major pain.
In other words, by default, without a "From" header, your email would be sent by "Nobody". You can still have 'nobody' (i.e. PHP) run the process and put a valid "From" header in the message.
On the off chance the latter is true
$header = "From: Name Lastname <myname@mydomain.com>\r\n";
should do it for you
Oh how I wish it was just the sender field!
I figured that was unlikely, but thought I would mention it.
Does your host have some other method of sending automated mails? I've just used php, but my main host has things like CGIEmail, and FormMail and a variety of "off the shelf" solutions for people who don't want to do their own scripting.
Your problem will most likely follow you around from host to host. They are checking the envelope now to see who an e-mail is really from to try and cut down on spam. If you are hosted on a *nix platform you can add a 5th parameter to the mail command to tell sendmail to set the envelope to a specified email address.
mail("etc","etc","etc","etc","-fyouremail@whatever.com");
This fifth parameter was added in PHP 4.0.5. Since PHP 4.2.3 this parameter is disabled in safe_mode and the mail() function will expose a warning message and return FALSE if you're trying to use it.
If you are on hosted on windows you can try:
ini_set(sendmail_from, $submitted_email);
//your actual mail command here
ini_restore(sendmail_from);
?>
What it does is temporarly set the Default sendmail_from email address to the submitted email address and then after the mail action has been completed, it set's it back to the default that has been assigned in the httpd.conf.
The nobody email address is that of the webserver.
Unfortunately, the problem is not that his mail is being refused by the destination server, but that 'nobody' (i.e. the user running the php process) is not allowed to run mail. So he can't actually get to the point where he can supply an alternative "from" field.
Tom
I guess phpmailer [phpmailer.sourceforge.net] is a packaged solution if you don't feel like writing your own.[/url]