作者:work24 字体: 类型:转载
这篇文章主要介绍了php带抄送和密件抄送的邮件发送方法,涉及php中mail函数的使用技巧,非常具有实用价值,需要的朋友可以参考下
本文实例讲述了php带抄送和密件抄送的邮件发送方法。分享给大家供大家参考。具体分析如下:
程序中用到了php的mail函数,该函数定义如下:
bool mail ( string $to , string $subject , string $message ] )
如果邮件发送成功返回True,否则返回False
Send email with CC and BCC
后端php代码,保存为sendmail.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@\n"; $mailheader.= "Return-Path: " . "support@\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.
"; }?>
希望本文所述对大家的php程序设计有所帮助。
免责申明:本栏目所发资料信息部分来自网络,仅供大家学习、交流。我们尊重原创作者和单位,支持正版。若本文侵犯了您的权益。请点击这里