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程序设计有所帮助。

相关文章

Cygwin中安装PHP方法步骤

1.在Cygwin中安装apt-cyg包管理工具 复制代码 代码如下: $ wget http://apt-cyg.googlecode.com/svn/trunk/apt-cyg $...

PHP的substr_replace将指定两位置之间的字符替换为*号

复制代码 代码如下:$username = "zongzi"; echo substr_replace($username,'**','1','2'); 定义和用法 substr_r...

浏览器关闭后,能继续执行的php函数(ignore_user_abort)

多的不说,直接上代码: 复制代码 代码如下: ignore_user_abort(true); //设置客户端断开连接时是否中断脚本的执行 set_time_limit(0); $fil...

php+ajax实现的点击浏览量加1

下面就分享一段相对完整的能够在实际应用中派上用场的代码,此代码是ajax结合php代码实现的。 一.ajax代码如下: <!DOCTYPE html> <html&...

使用迭代器 遍历文件信息的详解

1.迭代文件的行复制代码 代码如下:        public static IEnumerable<str...