Forum Moderators: coopster
My host decided to disallow mails from 'nobody' ('nobody' is the user of PHP+Apache) due to spam problems.
I use the PHP mail function to send out a confirmation email for new users, and it doesn't work.
I checked this thread:
[webmasterworld.com...]
but there isn't any solution there.
Any similar problem? Thx.
you could use something like this
$headers = '';
$headers .= "From: " . $name . " <" . $sourceemail . ">\r\n";
$headers .= "Return-Path: " . $sourceemail . "\r\n";
$headers .= "Reply-To: " . $sourceemail . "\r\n";
$headers .= "Content-type: text;\r\n";
$headers .= "Mime-Version: 1.0\r\n";
$sourceemail being the address it is coming from
This email is to inform you of a change that will affect customers utilizing PHP email scripts.Starting on Thursday, September 15th, you will need to specify your mail server and list a valid email address as your 'Send Mail From' address.
So in your PHP email script:
/* Specify your SMTP Server, Port and Valid From Address */
ini_set("SMTP","mail.yourdomain.com");
ini_set("smtp_port","25");
ini_set("sendmail_from","fromYou@yourdomain.com.com");The you@yourdomain.com must be a valid email address. Please see Article # 737 ("PHP Email Example") in our Knowledge Base for the entire sample script.
This is being enacted to enhance the security of our mail servers and prevent spam practices. Should you have any questions or concerns,
<?PHP
/* Setup your Subject and Message Body */
$subject='Testing PHP Email';
$body='Put Your Text Message Here.';
/* Specify your SMTP Server, Port and Valid From Address */
ini_set("SMTP","mail.yourdomain.com");
ini_set("smtp_port","25");
ini_set("sendmail_from","fromYou@yourdomain.com");
/* Additional Headers */
$headers = "Cc:Real CC Name <ccUser@theirdomain.com>\r\n";
$headers .= "Bcc:Real BCC Name <bccUser@theirdomain.com>\r\n";
/* Try to send message and respond if it sends or fails. */
if(mail ('ToPersonsName <toPerson@theirdomain.com>', $subject, $body, $headers )){
echo "<h2>Your Message was sent!</h2>";
}
else{
echo "<font color='red'><h2>Your Message Was Not Sent!</h2></font>";
}
exit;
?>