Jump to content

html in a mail


wannabe_god

Recommended Posts

I made a contact form on my page, and the code when sent is

<?php	//send mail	if ($_GET["p"] == "sendmail"){		$text="This mail comes from: " . $_POST["from"] . "\n<hr />\n\n" . str_replace("script","-script-",$_POST["message"]);		if (isset($_POST["message"]) && isset($_POST["from"])){ //gonna make it better			echo("<div class=\"info\">");			if (mail("***@hotmail.com",$_POST["subject"],$text))				echo("Mail succesfully sent :D");			else				echo("Mail could not be sent :(");			echo("</div>");			}	}(...)?>

almost everything workes fine, just hotmail returns just <hr /> in my mail program, and i dont understand why, i didnt used htmlspecialchars() or something like that.... :)edit: the problem is not very urge - i used just ____________ instead of <hr />, but i prefer making <hr /> work :)

Link to comment
Share on other sites

By default, email you send is text, not HTML. Check the mail reference for the full story:http://www.php.net/manual/en/function.mail.phpBut you need to send these headers with the mail to make it an HTML message:

// 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";

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...