Forum Moderators: coopster

Message Too Old, No Replies

'Nobody' disalowed from sending email with PHP - any quick fixes?

Yeah I;m changing host but in the meantime...

         

stuartmcdonald

3:13 pm on Jul 29, 2004 (gmt 0)

10+ Year Member



My rapidly deteriorating host today decided to disallow mails from 'Nobody' due to spam problems.

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.

drbrain

3:18 pm on Jul 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Can you run a system process?

You may be able to run a command using su (switch user) as another user that sends your mail.

stuartmcdonald

3:36 pm on Jul 29, 2004 (gmt 0)

10+ Year Member



No, its shared hosting... i think I'm stuffed, I was hoping for a PHP workaround, but after more rsearching have realised that its cause PHP is running as nobody that the mail is going out that way.

Talk about the last thing I needed to happen right now!

ergophobe

4:12 pm on Jul 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Just for clarification, is your host disallowing user 'nobody' from running a mail process or disallowing mails that don't have valid addresses in the From field?

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

PatrickDeese

4:16 pm on Jul 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I believe that if you populate the from field, as someone else suggested, it should work fine.

My contact scripts use the sender's email address from the email field as the from - it works most of the time and means I can "reply" without copy & paste (barring the occasional typo).

stuartmcdonald

4:19 pm on Jul 29, 2004 (gmt 0)

10+ Year Member



Just for clarification, is your host disallowing user 'nobody' from running a mail process or disallowing mails that don't have valid addresses in the From field?

They are disallowing user 'nobody' from running a mail process... Oh how I wish it was just the sender field!

amznVibe

4:34 pm on Jul 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Maybe call a perl program to send the email?

ergophobe

4:59 pm on Jul 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month




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.

stuartmcdonald

11:44 pm on Jul 29, 2004 (gmt 0)

10+ Year Member



I abused the host long enough to get them to turn it on again for the next two days to allow me time to write a workaround (little do they know, workaround is code for move to a new server!)

Thanks for the suggestions all.

bryangreen

11:59 am on Aug 25, 2004 (gmt 0)

10+ Year Member



Check out:
[us4.php.net...]

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.

ergophobe

3:12 pm on Aug 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Welcome to WebmasterWorld Bryan Green.

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

bryangreen

3:19 pm on Aug 25, 2004 (gmt 0)

10+ Year Member



Oh, my misunderstanding. I should've known the solution to what I thought was the problem was to obvious not to already have been posted.

coopster

7:30 pm on Aug 25, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



You could get creative using fsockopen() [php.net] ;)

I guess phpmailer [phpmailer.sourceforge.net] is a packaged solution if you don't feel like writing your own.[/url]

stuartmcdonald

10:53 pm on Aug 25, 2004 (gmt 0)

10+ Year Member



I ended up switching hosts - though as was said this problem may follow me. Will look into the PHPmailer - thanks!