搜尋
首頁php教程PHP源码【PHP】发送带抄送(CC)和秘送(BCC)的邮件

跳至    
<HTML>
  <HEAD>
  <TITLE>Send email with CC and BCC</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>Subject</b></DIV></TD>
      <TD><INPUT name=mailsubject size=35></TD></TR>
    <TR>
      <TD>
        <DIV align=right><b>Message</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=Submit></DIV>
    </TD>
    </TR>
   </TBODY>
   </TABLE>
  </FORM>
  </BODY>
</HTML>



2. [代码]sendemailWithCC_BCC.php     跳至       

<html>
  <head>
  <title>Mail Sent</title>
  </head>
  <body>
  <?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 <sales@yourdomain.com>\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 "<center><b>Mail sent to ". "$to". "<br>";
    echo $mailsubject. "<br>";
    echo $mailbody. "<br>";
    echo $mailheader. "<br>";
    if ($result) {
       echo "<p><b>Email sent successfully!</b></p>";
    }else{
       echo "<p><b>Email could not be sent. </b></p>";
    }
  ?>
  <p align="center">
  <table><tr><td width="66"><p align="right"><b>To</b></p></td>
             <td width="308"><b><?php echo $mailtoname . " [". $mailtomail . " ]";?></b></td></tr>
         
         <tr><td width="66"><p align="right"><b>CC</b></p></td>
             <td width="308"><b><?php echo $mailcc;?></b></td></tr>
         <tr><td width="66"><p align="right"><b>BCC</b></p></td>
             <td width="308"><b><?php echo $mailbcc; ?></b></td></tr>
         <tr><td width="66"><p align="right"><b>Priority</b></p></td>
             <td width="308"><b><?php echo $mailpriority;?></b></td></tr>
         <tr><td width="66"><p align="right"><b>Subject </b></p></td>
             <td width="308"><b><?php echo $mailsubject;?></b></td></tr>
         <tr><td width="66"><p align="right"><b>Message</b></p></td>
             <td width="308"><b><?php echo $mailbody;?></b></td></tr>
  </table>
  </p>
  </body>
</html>



陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

AI Hentai Generator

AI Hentai Generator

免費產生 AI 無盡。

熱門文章

R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
2 週前By尊渡假赌尊渡假赌尊渡假赌
倉庫:如何復興隊友
1 個月前By尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒險:如何獲得巨型種子
4 週前By尊渡假赌尊渡假赌尊渡假赌

熱工具

Dreamweaver Mac版

Dreamweaver Mac版

視覺化網頁開發工具

SublimeText3 Linux新版

SublimeText3 Linux新版

SublimeText3 Linux最新版

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

SublimeText3 英文版

SublimeText3 英文版

推薦:為Win版本,支援程式碼提示!

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

強大的PHP整合開發環境