无法使用html格式的php邮件从服务器发送邮件

时间:2014-09-22 09:53:05

标签: php linux

我正在尝试使用php邮件功能发送邮件,它可以正常使用以下代码:

<?php
$to = "abhwebdesign@gmail.com";
$subject = "subject";
$password="xxxxx";
$message = "
<html>
<head>
<title>HTML email</title>
</head>
<body >
<div style='width:670px;height:450px;padding:50px;background-color:#EFEFEB;'>
<div style='width:600px;height:450px;background-color:#FFFFFF;color:#105b94;font-size:20px;padding:10px'>
<img src='http://www.example.com/Images/Index/Logo.png' />
<p>Hi,</p>
<table style='color:#105b94;font-size:20px;'>
<tr>
<td><p>Thank you for registering with us.</p></td>
</tr>
<tr>
<td><br>Your password is :$password<br><br>We appreciate your interest.
</td>
</tr>
<tr>
<td><hr>Contact Us <br>Office :9999999999<br>www.example.com
</td>
</tr>
</table>
</div>
</div>
</body>
</html>
";

// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

// More headers
$headers .= 'From: Support <support@example.com>' . "\r\n";


mail($to,$subject,$message,$headers);
?>

如果我从以上代码中移除www.example.com并且#34; Office:9999999999
www.example.com
&#34;请帮帮我。

1 个答案:

答案 0 :(得分:0)

我强烈建议您使用:http://swiftmailer.org/

这包括邮件标题和配置。它管理着你不想看的所有东西。

亲切的问候!