【www.gdgbn.com--邮件】

语法
mail(to,subject,message,headers,parameters)参数 描述
to 必需。规定 email 接收者。
subject 必需。规定 email 的主题。注释:该参数不能包含任何新行字符。
message 必需。定义要发送的消息。应使用 lf (n) 来分隔各行。
headers 可选。规定附加的标题,比如 from、cc 以及 bcc。

应当使用 crlf (rn) 分隔附加的标题。
 
parameters 可选。对邮件发送程序规定额外的参数。


*/
$to="nobody@example.com";        //定义邮箱地址
$subject="mail";           //定义发送邮件的主题
$message="hello,php";         //定义邮件主体内容
$headers="from:webmaster@example.com"."rn".
"reply-to:webmaster@example.com"."rn".
 "x-mailer:php/".phpversion();        //定义附加信息
mail($to,$subject,$message,$headers);      //发送邮件
?>
//发送html格式的邮件例子
$to="test@example.com".",";
$to.="test1@example.com";        //定义多个收件人地址
$subject="mailhtml";          //定义邮件标题
//下面是邮件的html代码
$message="


birthday reminders for august


here are the birthdays upcoming in august!



 
    persondaymonthyear
 
 
    joe3rdaugust1970
 
 
    sally17thaugust1973
 



";
//发送http请求
$headers="mime-version:1.0"."rn";        //定义附加信息
$headers.="content-type:text/html;charset=iso-8856-1"."rn";
$headers.="to:mary,kelly"."rn";
$headers.="from:birthday reminder"."rn";
$headers.="cc:birthdayarchive@example.com"."rn";
$headers.="bcc:birthdaycheck@example.com"."rn";
mail($to,$subject,$message,$headers);       //执行发送操作

/*

注释:php 需要一个已安装且正在运行的邮件系统,以便使邮件函数可用。所用的程序通过在 php.ini 文件中的配置设置进行定义

*/

本文来源:http://www.gdgbn.com/jsp/28425/