php邮件|添加多个收件人

时间:2017-12-15 01:45:59

标签: php email

我一直在尝试修改此PHP代码(工作代码)以向多个收件人发送电子邮件:

if(!isset($hasError)) {

        $emailTo = $contact_email;
        $subject = $subject;    
        $body = "Name: $name \n\nEmail: $email \n\nMessage: $comments";
        $headers = 'From <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email;

        wp_mail($emailTo, $subject, $body, $headers);

        $emailSent = true;

}

我的解决方案:

if(!isset($hasError)) {

        $emailTo = $contact_email;
        $subject = $subject;    
        $body = "Name: $name \n\nEmail: $email \n\nMessage: $comments";
        $headers = 'From <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email;
        $headers .= 'BCC hello@mymail.com'. . "\r\n";

        //wp_mail($emailTo, $subject, $body, $headers);
        wp_mail(null, $subject, $body, $headers);

        $emailSent = true;

}

我的解决方案不起作用。我尝试过多种情况,但我仍然陷入困境。如何添加多个收件人?

1 个答案:

答案 0 :(得分:0)

$headers .= 'BCC hello@mymail.com'."\r\n";

Ther是bcc行中的一个额外点。