程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> PHP編程 >> 關於PHP編程 >> php發送html格式文本郵件的方法,

php發送html格式文本郵件的方法,

編輯:關於PHP編程

php發送html格式文本郵件的方法,


本文實例講述了php發送html格式文本郵件的方法。分享給大家供大家參考。具體實現方法如下:

<?php 
$to = "[email protected], [email protected]"; //設置收件人 
$subject = "This is a test"; //設置E-mail主題 
//設置E-mail內容:
$message = " 
<html> 
<head> 
<title>This is a test</title> 
</head> 
<body> 
<p>Dear all,</p> 
<p>This is a test for HTML mail sending.</p> 
</body> 
</html> 
"; 
//設置郵件頭Content-type header 
$header = "MIME-Version: 1.0/r/n"; //設置MIME版本 
$header .= "Content-type: text/html; charset=iso-8859-1/r/n"; //設置內容類型和字符集 
//設置收件人、發件人信息 
$header .= "To: Simon <[email protected]>, Elaine <[email protected]>/r/n"; //設置收件人 
$header .= "From: PHP Tester <[email protected]>/r/n"; //設置發件人 
$header .= "Cc: [email protected]/r/n"; // 設置抄送 
$header .= "Bcc: [email protected]/r/n"; // 設置暗抄 
echo $header; 
mail($to, $subject, $message, $header); //發送郵件 
?>

希望本文所述對大家的php程序設計有所幫助。

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved