[英]issue in body of the e-mail in php
I am sending mail by php and in the message part, my code is like: 我通过php发送邮件,在消息部分,我的代码如下:
$email_body = "<style type=\"text/css\">
p {padding:0 !important; margin:0 !important;}
td {padding:0 10px !important; margin:0 !important; font-family:Verdana, Geneva, sans-serif;}
td table td {padding:0 !important;}
</style>
<table align=\"center\" border=\"0\" cellpadding=\"10\" cellspacing=\"0\" style=\"border-collapse:collapse; border:1px solid #565656; font-family:Verdana, Geneva, sans-serif; width:800px; margin-top:0px; color:#565656;font-weight:normal;font-size:12px; text-align:justify; line-height:1.5em\">
<tbody>
<tr>
<td style=\"border-collapse:collapse; padding-top:10px !important;\">
message
</td>
</tr>
</tbody>
</table>";
But in my mail I am getting the full html code whatever it is written for $email_body instead of tabular format. 但是在我的邮件中,无论是为$ email_body而不是表格格式编写的,我都获得完整的html代码。 How to do that?
怎么做? Thanks.
谢谢。
You need to set the correct headers: 您需要设置正确的标题:
$to = 'foo@bar.baz';
$subject = 'foobar';
$message = '...'; // the html
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
mail($to, $subject, $message, $headers);
Have a look at the manual: http://php.net/manual/en/function.mail.php 看看手册: http : //php.net/manual/en/function.mail.php
You also need a complete html doc, that is: 您还需要一个完整的html文档,即:
html
head
title
style
body
table
And a tip, if you send html mails, don't use the style tag. 提示,如果您发送html邮件,请不要使用样式标签。 I often use this premailer: http://premailer.dialect.ca/
我经常使用此预邮寄器: http ://premailer.dialect.ca/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.