Forum Moderators: coopster

Message Too Old, No Replies

mail function won't work

         

andrewsmd

6:16 pm on Nov 2, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm trying to send an email using the mail() function. I get this error when I try to send.
Warning: mail() [function.mail]: SMTP server response: 550 Sender is not allowed. in c:\path_to_file\test.php on line 8
Mail Sent.
And here is my code.

$to = "webmaster@example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "webmaster@example.com";
$headers = "From: $from";
mail($to,$subject,$message,$headers);

Any ideas on what I can do? Thanks,

[edited by: dreamcatcher at 6:43 pm (utc) on Nov. 2, 2009]
[edit reason] use example.com. Thanks. [/edit]

TheMadScientist

10:02 pm on Nov 2, 2009 (gmt 0)

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



The only thing I see at a glance is no line break on the $from, and I know different servers have different issues with the whole \r\n thing, but maybe try:

$headers = "From: " . $from . "\r\n";

andrewsmd

9:10 pm on Nov 3, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That didn't work. I should mention that we upgraded from PHP 5.2.5 to 5.2.11. Why would that kill our mail function now?

andrewsmd

9:44 pm on Nov 3, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Got it, I removed the default sender from in the php.ini file and it worked. Thanks,

rocknbil

2:33 am on Nov 4, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Some mail servers don't seem to like the to and from being the same address, try making one of them something else, if you haven't already.