2014-02-11 24 views
-5

如何转换此邮件为HTML的Sendmail作为HTML输出

$message =' Hello ' . $row['first_name'] . ' ' . $row['last_name'] . ' 

以下是您的登录信息:

Username: '.$row['username'].'; 
Password: '.$row['password'].'; 

我们建议您更改密码,一旦你已经登录。

mail ($row[email], 'Login Information', $message, 'From: ' . $company . ' <' . $row['email'] . '>'); 
$sent = true; 

像这样:

$message =' 
<*html> 
<*head> 
<*title>HTML email<*/title> 
<*/head> 
<*body> 
<*div>Hello ' . $row['first_name'] . ' ' . $row['last_name'] . '<*/div> 
<*p>John<*/p> 
<*img src="image.png" alt="" > 
<*/body> 
<*/html> 
'; 
+2

什么是U试图做??? – ghost

+0

尝试以HTML格式发送邮件 – MARGELANI

+0

也许PHPMailer库可以帮助您发送html邮件:https://github.com/PHPMailer/PHPMailer –

回答

0

添加Content-type:text/html;charset=UTF-8你头和HTML标签删除*这样

$headers = "MIME-Version: 1.0" . "\r\n"; 
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n"; 
$headers .= "From: <****@example.com>' . "\r\n"; 
$headers .= "Cc: ****@example.com' . "\r\n"; 
$message =" 
<html> 
<head> 
<title>HTML email</title> 
</head> 
<body> 
<div>Hello " . $row['first_name'] . " " . $row['last_name'] . "</div> 
<p>John</p> 
<img src='image.png' alt='' > 
</body> 
</html> 
"; 


mail("tomailid","subject",$message,$headers);