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中Object对象的笔记分享

1.当将所有实例设为null,php会自动清除对象的引用。 2.建构子:__construct() 清除对象时自动执行的方法:__destruct() 也可以设置手动清除对象的方法:de...

PHP微信网页授权的配置文件操作分析

PHP微信网页授权的配置文件操作分析

本文实例讲述了PHP微信网页授权的配置文件操作。分享给大家供大家参考,具体如下: 代码如下: <?php //配置文件 return [ 'weixin'=>...

PHP多维数组排序array详解

PHP数组Array按字段排序 /** * Sort array by filed and type, common utility method. * @param...

thinkphp中的多表关联查询的实例详解

thinkphp中的多表关联查询的实例详解  在进行后端管理系统的编程的时候一般会使用框架来进行页面的快速搭建,我最近使用比较多的就是thinkphp框架,thinkphp框架...

sourcesafe管理phpproj文件的补充说明(downmoon)

sourcesafe管理phpproj文件的补充说明(downmoon)

后来发现sourcesafe管理界面,(Admin登录),tools——Options——File Types——File Group——Add "PHP"——“*.php;*.phpp...