Page 1 of 1

SOLVED: How to send a HTML mail

Posted: Sun Jul 18, 2010 6:13 pm
by mister_v
Hi,

I want to send a HTML-mail.

I know to use the mail-function.
But it only send text, not in HTML format.

Thanks,

Re: How to send a HTML mail

Posted: Sun Jul 18, 2010 8:33 pm
by chris
With PHP it is easily done.

You create the body of your message in html.
Don't forget <html><body></body></html>

and in the headers you tell it is a HTML-mail with the following line:

Code: Select all

Content-type: text/html\r\n
So the complete code looks something like this:

Code: Select all

$email='someone@somewhere.com';
$subject='This is the Subject;
$headers  = "From: me@here.com\r\n";
$headers .= "Content-type: text/html\r\n";

$body='<html><body><h1>My HTML mail:</h1>and the rest of the mail</body></html>';

mail($email,$subject,$body,$headers);
If you have more questions, just let me know.