php带抄送和密件抄送的邮件发送方法

前端之家收集整理的这篇文章主要介绍了php带抄送和密件抄送的邮件发送方法前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

本文实例讲述了PHP带抄送和密件抄送的邮件发送方法分享给大家供大家参考。具体分析如下:

程序中用到了PHP的mail函数,该函数定义如下: bool mail ( string $to,string $subject,string $message [,string $additional_headers [,string $additional_parameters ]] ) 如果邮件发送成功返回True,否则返回False

Send email with CC and BCC
To
Name
E-mail

CC
BCC
Priority
Subject
Message

后端PHP代码,保存为sendmail.PHP

PHP;"> Send Mail Script PHP $message= " " ; if (empty ( $mailtoname) || empty ( $mailtomail) ) { die ( "Recipient is blank! ") ; }else{ $to = $mailtoname . " <" . $mailtomail . ">" ; } if ( empty ( $mailsubject) ) { $mailsubject=" "; } if (($mailpriority>0) && ($mailpriority<6)) { $mailheader = "X-Priority: ". $mailpriority ."\n"; } $mailheader.= "From: " . "Sales Team \n"; $mailheader.= "X-Sender: " . "support@yourdomain.com\n"; $mailheader.= "Return-Path: " . "support@yourdomain.com\n"; if (!empty($mailcc)) { $mailheader.= "Cc: " . $mailcc ."\n"; } if (!empty($mailbcc)) { $mailheader.= "Bcc: " . $mailbcc ."\n"; } if (empty($mailbody)) { $mailbody=" "; } $result = mail ($to,$mailsubject,$mailbody,$mailheader); echo "
Mail sent to ". "$to". "
"; echo $mailsubject. "
"; echo $mailbody. "
"; echo $mailheader. "
"; if ($result) { echo "

Email sent successfully!

"; }else{ echo "

Email could not be sent.

"; } ?>
To
CC
BCC
PrioritySubject Message

希望本文所述对大家的PHP程序设计有所帮助。

php发送发送发送密件抄送抄送方法方法方法邮件邮件

猜你在找的PHP相关文章