Jump to content

Recommended Posts

Posted

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

Posted (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 by TCH-Andy

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...