php实现的抄送与密送电子邮件的代码,如下:
<HTML> <HEAD> <TITLE>发送邮件 with CC and BCC-www.jb200.com</TITLE> </HEAD> <BODY> <FORM action="sendemailWithCC_BCC.php" method=post name=form1> <TABLE> <TBODY> <TR> <TD> <DIV align=right><b>To</b></DIV></TD> <TD> <p>Name <INPUT name=mailtoname size=35><BR>E-mail <INPUT name=mailtomail size=35></p></TD></TR> <TR> <TD> <DIV align=right><b>CC</b></DIV></TD> <TD><INPUT name=mailcc size=35> </TD></TR> <TR> <TD> <DIV align=right><b>BCC</b></DIV></TD> <TD><INPUT name=mailbcc size=35> </TD></TR> <TR> <TD> <DIV align=right><b>Priority</b></DIV></TD> <TD><SELECT name=mailpriority> <OPTION value=1>Highest</OPTION> <OPTION value=2>High</OPTION> <OPTION selected value=3>Normal</OPTION> <OPTION value=4>Low</OPTION> <OPTION value=5>Lowest</OPTION> </SELECT> </TD></TR> <TR> <TD><DIV align=right><b>邮件主题:</b></DIV></TD> <TD><INPUT name=mailsubject size=35></TD></TR> <TR> <TD> <DIV align=right><b>邮件内容:</b> </DIV></TD> <TD><TEXTAREA cols=50 name=mailbody rows=7></TEXTAREA> </TD></TR> <TR> <TD colSpan=2> <DIV align=center><INPUT name=Submit type=submit value="提交"></DIV> </TD> </TR> </TBODY> </TABLE> </FORM> </BODY> </HTML> <!-- sendemailWithCC_BCC.php <html> <head> <title>发送电子邮件-www.jb200.com</title> </head> <body> <?php $message= " " ; if (empty ( $mailtoname) || empty ( $mailtomail) ) { die ( "收件人不能为空 ") ; }else{ $to = $mailtoname . " <" . $mailtomail . ">" ; } if ( empty ( $mailsubject) ) { $mailsubject=" "; } if (($mailpriority>0) && ($mailpriority<6)) { $mailheader = "X-Priority: ". $mailpriority ."n"; } $mailheader.= "From: " . "Sales Team <sales@yourdomain.com>n"; $mailheader.= "X-Sender: " . "support@yourdomain.comn"; $mailheader.= "Return-Path: " . "support@yourdomain.comn"; 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 "<center><b>Mail sent to ". "$to". "<br>"; echo $mailsubject. "<br>"; echo $mailbody. "<br>"; echo $mailheader. "<br>"; if ($result) { echo "<p><b>邮件发送成功!</b></p>"; }else{ echo "<p><b>邮件未能完成投递! </b></p>"; } ?> <div align="center"> <table><tr><td width="66"><div align="right"><b>To</b></div></td> <td width="308"><b><?php echo $mailtoname . " [". $mailtomail . " ]";?></b></td></tr> <tr><td width="66"><div align="right"><b>CC</b></div></td> <td width="308"><b><?php echo $mailcc;?></b></td></tr> <tr><td width="66"><div align="right"><b>BCC</b></div></td> <td width="308"><b><?php echo $mailbcc; ?></b></td></tr> <tr><td width="66"><div align="right"><b>Priority</b></div></td> <td width="308"><b><?php echo $mailpriority;?></b></td></tr> <tr><td width="66"><div align="right"><b>Subject </b></div></td> <td width="308"><b><?php echo $mailsubject;?></b></td></tr> <tr><td width="66"><div align="right"><b>Message</b></div></td> <td width="308"><b><?php echo $mailbody;?></b></td></tr> </table> </div> </body> </html> -->