问题描述
当我在邮件中使用简单的文本正文时,它工作正常,但是当我尝试发送html邮件时,它却无法工作。
请同时检查我的两个脚本。
简单邮件正常工作
$mailto="[email protected]"; //Enter recipient email address here
$subject = "Email Confirm";
$from="[email protected]>"; //Your valid email address here
$message_body = 'You Have an Mail';
mail($mailto,$subject,$message_body,"From:".$from);
echo "Your email has been sent successfully";
HTML邮件正文不起作用
$mailto="[email protected]"; //Enter recipient email address here
$subject = "Email Confirm";
$from="[email protected]"; //Your valid email address here
// To send HTML mail,the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Create email headers
$headers .= 'From: '.$from."\r\n".
'Reply-To: '.$from."\r\n" .
'X-Mailer: PHP/' . PHPversion();
$message_body = '
<html>
<head>
<title>Welcome to CodexWorld</title>
</head>
<body>
<h1>Thanks you for joining with us!</h1>
<table cellspacing="0" style="border: 2px dashed #FB4314; width: 100%;">
<tr>
<th>Name:</th><td>CodexWorld</td>
</tr>
<tr style="background-color: #e0e0e0;">
<th>Email:</th><td>[email protected]</td>
</tr>
<tr>
<th>Website:</th><td><a href="http://www.codexworld.com">www.codexworld.com</a></td>
</tr>
</table>
</body>
</html>';
mail($mailto,$headers,"From:".$from);
echo "Your email has been sent successfully";
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)