Forum Moderators: coopster
Below is an excerpt from a script that sends a confirmation email to those who sign up at my site. I'm confused about the headers. What do the \n and \r\n mean? Also, what headers here are necessary and what aren't? I ask because the emails that form sends never go through (the message "email sent" appears, but the emails are not received). Is there any way I can simplify this, assuming the address the mail sent from is me@mysite.com? If it's relevant, this is hosted on an Apache server, and I think it's Unix.
_______________________________________________________
function send_mail($mail_address, $num = 29) {
$header = "From: me@mysite.com\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Mailer: SquirrelMail version 1.4.3a\r\n";
$header .= "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n";
$header .= "Content-Transfer-Encoding: 8bit\r\n";
$subject = $this->messages(28);
$body = $this->messages($num);
if (mail($mail_address, $subject, $body, $header)) {
return true;
} else {
return false;
}
}
_____________________________________________________
Thanks. I appreciate all the pointers I've been given here.
\r\n = carriage return + line feed (Windows end of line)
Either will do but I would make them uniform not a mix of the two.
From: is the only required header listed here.
Try setting your own email address as the from and to address and see if you get a bounce.
The fact the emails don't get through could have something to do with the fact that the mail server considers it "relaying". Is either the from or to address in the domain that is hosted on the server?
Cheers,
Brad