当前位置:首页 > PHP教程 > PHP高级教程

php发送html格式文本邮件的方法

本文实例讲述了php发送html格式文本邮件的方法。分享给大家供大家参考。具体实现方法如下:

<?php 
$to = "simon@mailexample.com, elaine@mailexample.com"; //设置收件人 
$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 <simon@mailexample.com>, elaine <elaine@mailexample.com>/r/n"; //设置收件人 
$header .= "from: php tester <phptester@163.com>/r/n"; //设置发件人 
$header .= "cc: peter@mailexample.com/r/n"; // 设置抄送 
$header .= "bcc: david@mailexample.com/r/n"; // 设置暗抄 
echo $header; 
mail($to, $subject, $message, $header); //发送邮件 
?>

希望本文所述对大家的php程序设计有所帮助。


【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:)!