使用此示例代码。
<?php
//mail customer
$from = 'donotreply@mysite.co.uk';
$to = "email@example.com"; //write the email here.
$subject = 'Title of Email';
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: Name of Company <$from>\r\n";
$msg = '
<html>
<head>
<link href="http://linktocss/.../etc" rel="stylesheet" type="text/css" />
</head>
<body>
<p>I am testing this message.</p>
<a href="https://www.w3schools.com/html/">Visit our HTML tutorial</a>
<div>
This is a clear test to go back to the line.
</div>
Regards, <br>
Company Name.
</body>
</html>
';
mail($to, $subject, $msg, $headers) or die ("mail error");
?>
希望这可以帮助。