2014-02-11 49 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);