Forum Moderators: coopster

Message Too Old, No Replies

Mail Headers

         

inuwolf

6:56 pm on Mar 15, 2005 (gmt 0)

10+ Year Member



I've talked with my hosting service extensively, but they give me terse, unhelpful answers.

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.

badone

11:19 pm on Mar 15, 2005 (gmt 0)

10+ Year Member



\n = line feed (Unix end of line)

\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

inuwolf

12:11 am on Mar 16, 2005 (gmt 0)

10+ Year Member



Thanks. The email is marked as from no-reply@mysite.com, and the form is at mysite.com/mail.php. Isn't it standard procedure to have the mail hosted on the same server as the mail form?