“Nobody” prevented from sending emails
Forget what I said below, if your webhosting has disabled user “nobody” to sent email, then they should enable suphp. This way, all PHP script executes as user account and not nobody. And will deliver email correctly.
==========
So your webhosting provider activated “Prevent “nobody” from sending mail” which cause your PHP script can’t sent email? You can use PHP classes called XpertMailer or PHPMailer but somehow it’s not working well on my host. Weird… The previous version XPertMailer works like charm but somehow the new one never sent my emails.
So I googling around and found Webmaster World’s Forum, and luckily the ini_set function is not disabled. So I test the script and it works flawlessly. Below is the script
<?PHP
/* Setup your To, Subject and Message Body */
$to='MyRealName <me@mydomain.com>';
$subject='Testing PHP Email';
$body='Put Your Text Message Here.';
/* Specify your SMTP Server, Port and Valid from Address */
ini_set("SMTP","mail.mydomain.com");
ini_set("smtp_port","25");
ini_set("sendmail_from","me@mydomain.com");
/* Additional Headers */
$headers = "from:MyRealName <me@mydomain.com>\r\n";
//$headers .= "Cc:RealCCName <ccUser@theirdomain.com>\r\n";
//$headers .= "Bcc:RealBCCName <bccUser@theirdomain.com>\r\n";
/* Try to send message and respond if it sends or fails. */
if(mail ($to, $subject, $body, $headers )){
echo "<h2>Your Message was sent!</h2>";
}
else{
echo "<font color='red'><h2>Your Message Was Not Sent!</h2></font>";
}
exit;
?>
PS: email account me@mydomain.com should exist and password should be correct
Now what should I do if the disable function ini_set also?? Hmm…???