2007-01-14

How do I send e-mail from PHP in HTML format?


If you send an e-mail in the following format, the e-mail will be sent as plain text:

mail($to, $subject, $message);

To send e-mail in HTML format you need to add a fourth parameter $headers:

mail($to, $subject, $message, $headers),

where $header needs to contain the following text: Content-type: text/html; charset=us-ascii.


Example:


mail('example@example.com', 'Mail example', 'This text will appear in HTML format. Link: http://bvencel.blogspot.com', 'From:Somebody\r\n Reply-to: somebody@example.com\r\n Content-type: text/html; charset=us-ascii');

No comments: