crawlerbasher Posted May 17, 2010 Share Posted May 17, 2010 I've been looking all over the internet to find out what I'm doing wrong here. I've even tried looking at the source code of the email to match that for the template. But no matter what I try, I can't seem to get it the view the email with out it show all the html codes. This is the same for outlook 2007 and google mail. Below is part of the code for the emailing script. $title = strip_tags($_POST['Title']); $stroy = strip_tags($_POST['Story']); $email = strip_tags($_POST['Email']); $yourname = strip_tags($_POST['YourName']); $youremail = strip_tags($_POST['YourEmail']); $from_header = "From: $youremail" . "\r\n" . "Reply-To: $youremail" . "\r\n" . "MIME-Version: 1.0" . "\r\n" . "X-Mailer: PHP/" . phpversion() . "\r\n" . "Content-Language: en-gb"; if (is_numeric ($story)) { echo "Please go back and try again"; } else { require("config.php"); $con = mysql_connect($db_server, $db_username, $db_password); // Connects to your database if (!$con) { die('Could not connect: ' . mysql_error()); // error message when failed to connect. } mysql_select_db($db_name) or die(mysql_error()); $query = "SELECT * FROM TaruNews WHERE id = $stroy LIMIT 1"; $result = mysql_query( $query ); $num = mysql_num_rows($result); $data = mysql_fetch_assoc($result); if( $num > 0 ) { $text = $data['Story']; //send mail - $subject & $contents come from surfer input mail($email, $title, $text, $from_header); // redirect back to url visitor came from echo "<p><b>Thank you ".$yourname.", The Email as been sent to ".$email."<b></p>"; mysql_close($con); // close conection after information has been injected in to the mysql If anyone has any idea on resolving this issue please let me know. I've tried adding the html headers and footer tags around the $data['Story'] but that dose not work as well. I can't understand why the html codes are showing up rather than formatting the email it self. Link to comment https://forums.phpfreaks.com/topic/202009-using-php-to-email-html-emails/ Share on other sites More sharing options...
crawlerbasher Posted May 17, 2010 Author Share Posted May 17, 2010 ok found out what was going wrong, in the email header needed to add this. "Content-type:text/html; charset=US-ASCII" . "\r\n" blow the MINE type. Blow is what it looks like. // Insert you code for processing the form here, e.g emailing the submission, entering it into a database. $title = strip_tags($_POST['Title']); $stroy = strip_tags($_POST['Story']); $email = strip_tags($_POST['Email']); $yourname = strip_tags($_POST['YourName']); $youremail = strip_tags($_POST['YourEmail']); $from_header = "From: $youremail" . "\r\n" . "Reply-To: $youremail" . "\r\n" . "Content-type:text/html; charset=US-ASCII" . "\r\n". "MIME-Version: 1.0" . "\r\n" . "X-Mailer: PHP/" . phpversion() . "\r\n" . "Content-Language: en-gb"; Link to comment https://forums.phpfreaks.com/topic/202009-using-php-to-email-html-emails/#findComment-1059489 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.