I'm in a real pinch! I'm working on sending emails from my php script using mail(), but it's not working right.
Here is my code:
$subject = "email to parent of under 13";
$from = "somename";
$fromemail = "someemail";
$replyto = "somename";
$replytoemail = "someemail";
$emailFile = "emails/parentUnder13.html";
// open and read the text file to build the message of the email
$message = getMessage($emailFile,$lid);
// build the header information
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: $from <$fromemail>\r\n";
$headers .= "Reply-To: $replyto <$replytoemail>\r\n";
$headers .= "X-Priority: 3\r\n";
$headers .= "X-MSMail-Priority: Normal\r\n";
// send the email
if (mail($recipient, $subject, $message, $headers)) {
echo "<br />Email sent successfully to: ".$recipient;
} else {
echo "<br />Error sending email to: ".$recipient;
}
I'm generating the $recipient based on form input. Does it make a difference what $from and $replyto are?
I've been experimenting with this script for some time now using my personal and work email addresses, and it's worked fine. Then, for testing, I entered others emails addresses, and it's says the email was sent, but they are not receiving it. I'm not getting an error sending the mail, just recieving it. When I ran this script the first time, my mail program dropped the email into my junk folder, and I had to tell it that this is not junk. Now it's fine.
I hope I'm explaining this correctly. I've even tried removing the variables, and hard coding in test strings, and I still have the same problem, unless I send the email to my own personal address or my work address.
Then I tried the mail() function on a totally different server... same thing.
If anyone can help, I would greatly appreciate it.
Thanks,
Dan