asra7 Posted August 31, 2004 Posted August 31, 2004 Hello. I'm trying to send an html mail in php. The mail does get sent but the From header contains the name "Nobody" and email of nobody@server56.totalchoicehosting.com. I figured that I can overwrite these settings with the fourth parameter of the PHP built-in mail function but it looks like that isn't working. Even the MIME content type declaration of html is not working. In other words, the mail header parameter doesn't seem to be causing any effect on the mail being sent. I've tried separating the headers with \n, \r\n etc. but nothing seems to be working. The code is pasted below: Can anyone help? $mailheaders = "To: $_POST[fname] <$_POST>\n" . "From: CS <customerservice@deliveryoncall.com>\n" . "MIME-Version: 1.0\n" . "Content-type: text/html; charset=iso-8859-1\n\n"; mail($_POST, $subject, $message, $maiheaders); Regards, Asra Quote
TCH-Andy Posted September 1, 2004 Posted September 1, 2004 (edited) I use $myname = "my name"; $myemail = "name@myemail.com"; $contactname = "Name I'm sending to"; $contactemail = "name@to_someones_domain.com"; $subject = "Test msg from php script"; $message .= "Test message\n"; $message .= "\n"; $message .= "Andy\n"; $headers .= "From: $myname <$myemail>\r\n"; $headers .= "Reply-To: $myname <$myemail>\r\n"; $headers .= "To: $contactname <$contactemail>\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers .= "X-Priority: 1\r\n"; $headers .= "X-MSMail-Priority: High\r\n"; $headers .= "X-Mailer: Andy PHP test Mailer\n"; mail($contactemail, $subject, $message, $headers); This works fine - I've just tested it again. YOu will still get nobody showing up in the header, since it runs as nobody, but the from and reply-to addresses will be correct. Edited September 1, 2004 by TCH-Andy Quote
asra7 Posted September 1, 2004 Author Posted September 1, 2004 Wow, it is working, thanks a lot! But I'm still unable to understand where my code went wrong!!! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.