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

yipeiwu_com6年前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实现多维数组排序的方法示例

本文实例讲述了php实现多维数组排序的方法。分享给大家供大家参考,具体如下: //定义一个学生数组 $students = array( 256=>array('name'...

PHP中error_log()函数的使用方法

本文实例讲述了PHP中error_log()函数的使用方法。分享给大家供大家参考。具体分析如下: 今天遇到一个问题需要调试,但是只能通过日志打印调试,就用到了error_log这个函数...

PHP7内核CGI与FastCGI详解

PHP7内核CGI与FastCGI详解

CGI:是 Web Server 与 Web Application 之间数据交换的一种协议。 FastCGI:同 CGI,是一种通信协议,但比 CGI 在效率上做了一些优化。 PHP-...

php求数组全排列,元素所有组合的方法

本文实例讲述了php求数组全排列,元素所有组合的方法。分享给大家供大家参考,具体如下: <?php $source = array('pll','我','爱','你',...

基于PHP实现的多元线性回归模拟曲线算法

基于PHP实现的多元线性回归模拟曲线算法

本文实例讲述了基于PHP实现的多元线性回归模拟曲线算法。分享给大家供大家参考,具体如下: 多元线性回归模型: y = b1x1 + b2x2 + b3x3 +...... +bnxn;...