我试图发送一封电子邮件给我自己,它有一个布局和图像。我做错了什么?在php中发送html电子邮件的问题
<?php
$message = $_POST['message'];
$emailsubject = 'site.com';
$webMaster = '[email protected]';
$body = "
<html>
<body bgcolor=\"e7e7e7\">
<style type=\"text/css\">
#body {margin: auto;border: 0;padding: 0;font-family: Georgia, 'Times New Roman', Times, serif;font-size: 12px;}
#emailHeader {width: 500px;height: 131px;background: url(http://www.site.com/images/image.gif) no-repeat;}
#emailContent {width: 500px;background: url(http://www.site.com/images/image2.gif) repeat-y;text-align: left;padding: 0 33px 0 6px;}
#emailFooter {width: 500px;height: 34px;background: url(http://www.site.com/images/image3.gif) no-repeat;}
</style>
<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr>
<td valign=\"top\" align=\"center\">
<table width=\"500\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr>
<td id=\"emailHeader\"></td>
</tr>
<tr>
<td id=\"emailContent\">
content $message
</td>
</tr>
<tr>
<td id=\"emailFooter\"></td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>"
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailsubject, $body, $headers);
if ($success) {
echo "Your message was sent.";
}
else{
echo "There was a error.";
}
?>
发生什么事情并非您所期望的?你是否收到错误信息?如果是这样,什么? – Amber 2009-12-05 00:47:35
@PHPNooblet。你有什么问题?电子邮件是否显示不正确?是否根本没有显示?请编辑你的问题来解释。 – 2009-12-05 00:48:02
布局不显示。没有图片,任何东西。当我在HTML文件中查看布局时,它工作正常。 – PHPNooblet 2009-12-05 00:50:16