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

yipeiwu_com5年前PHP代码库

本文实例讲述了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程序设计有所帮助。

相关文章

php中根据某年第几天计算出日期年月日的代码

这个索引值除了方便面数据的记录和搜索,还起着记录日期资讯的作用,信息量很可观。 那么,如何还原索引值为可用的日期资讯呢? date('z')返回的是一年中的第几天,返回值为从0开始至36...

php中常见的sql攻击正则表达式汇总

本文实例讲述了php中常见的sql攻击正则表达式。分享给大家供大家参考。具体分析如下: 我们都已经知道,在MYSQL 5+中 information_schema库中存储了所有的 库名,...

PHP中通过fopen()函数访问远程文件示例

使用PHP不仅可以让用户通过浏览器访问服务器端的文件,还可以通过HTTP或FTP等协议访问其他服务器中的文件,可以在大多数需要用文件名作为参数的函数中使用HTTP和FTP URL来代替文...

PHP操作Memcache实例介绍

PHP操作Memcache实例介绍

b/s: 基于浏览器和服务器架构 web程序 c/s: QQ SVN client客户端+ 服务器简单的基于文本行的协议: redis memcache 区别: 都是存储数据的,memc...

php把数组值转换成键的方法

本文实例讲述了php把数组值转换成键的方法。分享给大家供大家参考。具体如下: function values2keys($arr, $value=1){ $new = array...