dk4210 Posted August 12, 2011 Share Posted August 12, 2011 Hello Guys, I have a strange issue that I am trying to figure out... I have a php mail script that I can't get the correct from email address to display in the email client Here is my code notice the $from2 var If I have this code - $headers = "From:'.$from2.'\r\n"; I get a default email address If I add this code - $headers = "From:example@example.com\r\n"; it works fine. // multiple recipients $to = $email; $from2 = $_SESSION['no_reply']; //echo "This is the from2" . $from2; //exit; // subject $subject2 = 'You have a new message from ' . $_SESSION['site_name'] .''; //begin of HTML message $message2 = 'You have a new message.<br>'; $message2 .= 'From: '. $username1; $message2 .= '<br>Message Details'; $message2 .= '<br><a href="'.$site_url .'">Log in to see the message</a>'; $message2 .= '<br><br><br>'; //end of message $headers = "From:'.$from2.'\r\n"; $headers .= "Content-type: text/html\r\n"; // Mail it mail($to, $subject2, $message2, $headers); I did echo out the $form2 to make sure it had a value and it does.. Please advise.. Thanks, Dan Quote Link to comment Share on other sites More sharing options...
WebStyles Posted August 12, 2011 Share Posted August 12, 2011 $headers = "From:".$from2."\r\n"; Quote Link to comment Share on other sites More sharing options...
chintansshah Posted August 12, 2011 Share Posted August 12, 2011 You can do this using mail($to, $subject2, $message2, "From: ".$form2); Quote Link to comment Share on other sites More sharing options...
dk4210 Posted August 12, 2011 Author Share Posted August 12, 2011 Hi WebStyles, I tried the following / multiple recipients $to = $email; //$from2 = "someonelse@".$url.""; $from2 = $_SESSION['no_reply']; //echo "This is the from2" . $from2; //exit; // subject $subject2 = 'You have a new message from ' . $_SESSION['site_name'] .''; //begin of HTML message $message2 = 'You have a new message.<br>'; $message2 .= 'From: '. $username1; $message2 .= '<br>Message Details'; $message2 .= '<br><a href="'.$site_url .'">Log in to see the message</a>'; $message2 .= '<br><br><br>'; //end of message $headers = "From:".$from2."\r\n"; $headers .= "Content-type: text/html\r\n"; // Mail it mail($to, $subject2, $message2, $headers); And it never sent the email at all chintansshah, I tried what told me to do and it just sent the default email address.. The strange thing is if I manually add the address in there it works fine but if I try to use a variable it malfunctions in one way or another.. Please advise Quote Link to comment Share on other sites More sharing options...
dk4210 Posted August 12, 2011 Author Share Posted August 12, 2011 Even though the var has correct value Quote Link to comment Share on other sites More sharing options...
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.