【问题标题】:PHP Mailer, need to add multiple Bcc [duplicate]PHP Mailer,需要添加多个密件抄送 [重复]
【发布时间】:2013-08-29 23:34:42
【问题描述】:

我一直在使用这个邮件程序,但现在我需要添加(多个)永久密件抄送地址。我该怎么做?

到目前为止,这是我的代码:

<?php

$message = '';

if (isset($_POST['email']) && !empty($_POST['email'])) {
    if (mail($_POST['email'], $_POST['subject'], $_POST['body'], "From: me@mydomain")) {
        $message = "Email has been sent to <b>".$_POST['email']."</b>.<br>";
    } else {
        $message = "Failed sending message to <b>".$_POST['email']."</b>.<br>";
    }
} else {
    if (isset($_POST['submit'])) { 
        $message = "No email address specified!<br>";
    }
} 

if (!empty($message)) {
    $message .= "<br><br>";
}

?>

【问题讨论】:

    标签: php sendmail bcc


    【解决方案1】:

    试试这个:

    <?php
        $thirdMail = "three@example.com\r\n";
        $header = "From: email@example.com\r\n";
        $header .= "BCC: one@example.com,two@example.com,".$thirdMail;
        mail($toMail, $subject, $message, $header);
    ?>
    

    如您所见,每个地址都用逗号分隔。

    【讨论】:

      【解决方案2】:

      See here,这将提供有助于在 mail() 中设置 cc 和 bcc 的详细信息。

      例如,

      $bcc = array_of_bcc_users;
      $headers = 'From: admin@website.com' . "\r\n";
      $headers .= 'BCC: '. implode(",", $bcc) . "\r\n";
      
      mail($to, $title, $content, $headers);
      

      【讨论】:

        【解决方案3】:

        试试这个可能对你有用:

        <?php
        $msgTo = "msgTo@email.com";
        $msgSubject = "Mail Subject";
        $msgContent = "This is the message,:)";
        
        $bcc = "msgbcc@email.com";
        
        $msgHeaders = "To: $msgTo\r\n";
        $msgHeaders .= "From: no-reply@email.com\r\n";
        $msgHeaders .= "Bcc: $bcc\r\n";
        $msgHeaders .= "X-Mailer: PHP".phpversion();
        
        $success = mail($msgTo, $msgSubject, $msgContent, $msgHeaders);?>
        

        【讨论】:

          猜你喜欢
          • 2017-08-28
          • 2015-12-19
          • 2012-12-23
          • 2014-10-28
          • 2023-03-20
          • 2016-12-19
          • 2016-10-19
          • 2015-10-01
          • 2013-01-01
          相关资源
          最近更新 更多