hi
I have a strange problem on my server.
php mail() function does not send emails.
The Prevent the user "nobody" from sending out mail to remote addresses is OFF.
What can I do?
I have cPanel 11.25.0-S43473 ...
thank's
hi
I have a strange problem on my server.
php mail() function does not send emails.
The Prevent the user "nobody" from sending out mail to remote addresses is OFF.
What can I do?
I have cPanel 11.25.0-S43473 ...
thank's
Please make sure that mail() is not blocked in your php.ini file.
mail() in the php ini file is ok...
from scripts like joomla emails working ok and use the php mail function...
I think that the server does not like emails from this script ...
mail($shopper_email,$shopper_subject,$shopper_message);
What can I do?
Last edited by pikuser5; 03-03-2010 at 04:12 PM.
mail is tricky because the failure could be anywhere in a long chain of processes. you should start by checking for the success or failure of your call to the mail function.
You may also find this thread useful as it discusses the points of failure and options other than the php mail func.
the script is ok because it works on another server ... !
......
anyone has any idea?
If it was ok you wouldn't be posting here.
You should always check the result of the mail function just in case it returns FALSE. From the documentation:
If your mail function returns FALSE then you would KNOW there's a problem with your mail configuration. If it returns TRUE then there could still be something wrong with your mail configuration. You would need to check the mail log in either case to see if you are getting any errors.Returns TRUE if the mail was successfully accepted for delivery, FALSE otherwise.
It is important to note that just because the mail was accepted for delivery, it does NOT mean the mail will actually reach the intended destination.
The kicker is that php may be handing off the mail, your server may be sending off the mail, and it may get spam filtered along the way.
I would highly recommend checking out that best practices thread.
You could try explicitly setting the From address using the -f parameter, as explained in example #3 in the php.net manual page for mail:
This once worked for me.PHP Code:<?php
mail('nobody@example.com', 'the subject', 'the message', null,
'-fwebmaster@example.com');
?>
Sorry for resurrecting an old thread but I am a complete noob on this stuff and confused!
Why does using
work? what does thePHP Code:<?php
mail('nobody@example.com', 'the subject', 'the message', null,
'-fwebmaster@example.com');
?>actually do?PHP Code:'-f'
The reason why I am asking is that I have just started using a VPS and my previous code worked fine and then it just stopped... I did a re-image hoping that would solve the problem and it didn't.
the code I was using was from excerpt 2 from php.net on mail
This new -f bit of code does solve it but I don't want to be ignorant, I know I have a mountain of info to climb to understand linux but I have got to start somewhere...PHP Code:<?php
$to = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>
Examining the email, it seems whatever comes after the "-f" comes up as the actual sender (when going through the internet headers) whereas nobody@example.com comes up in the From field in the email client.
Also what could have happened to my server for the original code from working (also mysql connection flipped out as well... I could connect to the database but not see any tables)?
cheers
Zen