chiefrokka Posted May 29, 2008 Share Posted May 29, 2008 I've been searching for an hour on these forums and trying all sorts of code people have posted for the Mail Headers syntax, but I keep getting the email and it returns the server host for "From: blahblah@linhost263.prod.mesa1.secureserver.net" can someone please post code that works with a variable for From: my latest attempt is: <?php $to = $Email; $headers = 'FROM: $Admin_Email'; $headers .= 'Reply-To: $Admin_Email'; $subject = 'work you piece of crap'; $headers = 'MIME-Version: 1.0' . '\r\n'; $headers .= 'Content-type: text/html; charset=iso-8859-1' . '\r\n'; ?> Quote Link to comment Share on other sites More sharing options...
trq Posted May 29, 2008 Share Posted May 29, 2008 Variables are not interpolated when within signle quoted strings, change them to double. Quote Link to comment Share on other sites More sharing options...
Gighalen Posted May 29, 2008 Share Posted May 29, 2008 Also, FROM: should be From: Quote Link to comment Share on other sites More sharing options...
chiefrokka Posted May 29, 2008 Author Share Posted May 29, 2008 hmm, still sending the servers address. I changed code to this. the message has some html that I took out because I use variables within the tables. <?php $to = $Email; $headers = "From: $Admin_Email"; $headers .= "Reply-To: $Admin_Email"; $subject = "Survivor League - $user's Week $Current_Week Pick!"; $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n"; $message = ' <html> <head> </head> <body> </body> </html> '; ?> Quote Link to comment Share on other sites More sharing options...
chiefrokka Posted May 29, 2008 Author Share Posted May 29, 2008 ok I figured it out finally. I took out these lines below and it works fine now. $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n"; so now all I have is: <?php $to = $Email; $headers = "From: $Admin_Email"; $headers .= "Reply-To: $Admin_Email"; ?> Quote Link to comment Share on other sites More sharing options...
chiefrokka Posted May 29, 2008 Author Share Posted May 29, 2008 ok I just realized that the From: $Admin_Email works but the HTML portion of the email doesn't show up properly without $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; so close but yet so far away. but when I put those 2 in the headers, the email doesn't use the $Admin_Email but sends the servers address. Is there a way to send HTML as well as using a variable for From: Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted May 29, 2008 Share Posted May 29, 2008 Each line of the header need a \r\n Quote Link to comment Share on other sites More sharing options...
chiefrokka Posted May 29, 2008 Author Share Posted May 29, 2008 <?php $to = $Admin_Email; $headers = "From: $Admin_Email \r\n"; $headers .= "Reply-To: $Admin_Email \r\n"; // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; ?> the above code didn't work. I have double quotes for part of the headers with variables then the last 2 are single quotes. do I have wrong syntax in the first 2 with? Quote Link to comment Share on other sites More sharing options...
fook3d Posted May 29, 2008 Share Posted May 29, 2008 <?php $to = $Admin_Email; $headers = "From: $Admin_Email \r\n"; $headers .= "Reply-To: $Admin_Email \r\n"; // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; ?> the above code didn't work. I have double quotes for part of the headers with variables then the last 2 are single quotes. do I have wrong syntax in the first 2 with? You are resetting the $headers value before you are not using the .= operator. Using the code below will show all the $header lines. <?php $to = $Admin_Email; $headers = "From: $Admin_Email \r\n"; $headers .= "Reply-To: $Admin_Email \r\n"; // To send HTML mail, the Content-type header must be set $headers .= "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n"; ?> To see what value it is returning, use echo $headers; below all the $headers variables. If this isn't what your asking, look past it, I'm a dumbass at times and don't fully understand your issue Quote Link to comment Share on other sites More sharing options...
chiefrokka Posted May 29, 2008 Author Share Posted May 29, 2008 ahh, that's what it was. I forgot the period before the = on the 'MIME-Version' line. you are the man. thank you 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.