Send HTML Email with PHP and mail()

« Return to Article

Demo

Your Email Address


PHP

$body_html = '
	<html>
		<head>
			<title>HTML Test Email</title>
			<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
		</head>
		<body>
			<p>
				This is a test.
			</p>
		</body>
	</html>
';

$from = 'sender@example.com';
$to = 'recipient@example.com';
$subject = 'HTML Test Email';
$headers = "From:$from\n" .
    "MIME-Version: 1.0\n" .
    "Content-type: text/html; charset=iso-8859-1";

mail($to, $subject, $body_html, $headers);

Donate

If you found this article useful and would like to see more like it this please consider making a donation.