im using the php mail() function to send an email and i got the email. except its formatted wrong like it looks like this:

<table bgcolor="black"><tr bgcolor="#111111"><td bgcolor="#222222"
width="60%"

etc.. u get it right?
i use gmail. now ive had images sent in mails to me. so why is this not working? i havent tested images but i figure that if table doesnt work img wont either. whats going on? is there a workaround? or is this what all mail sent by php mail() is bound to look like.

i have free hosting atm. or is it the hosting?
im clueless halp?!

Recommended Answers

All 4 Replies

Try following code

<?php
	$headers= "MIME-Version: 1.0\n";
	$headers.="Content-type: [b]text/html;[/b] charset=iso-8859-1\n";
	$headers.="cc: cc@daniweb.com\n";				
	$tomail="tosomeone@daniweb.com";

	$message="<bold>This is message for email</bold>\n\n<br><br>";
	$message.="<i>Nb : This message may be written in complete html format .</i>";
	mail($tomail,"This is mail subject ",$message,$headers);

?>

no brainer? LOL i didnt know that i had to format the headers that way! btw is there different charsets and content types?

no brainer? LOL i didnt know that i had to format the headers that way! btw is there different charsets and content types?

If you send it without headers the email will read it as plaintext and not render any html, with the above headers it lets the program know that there is html to be rendered in this document.

i know that but is there different kind of mail headers'?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.