I have this code part that’s responsible for getting the variables from the contact form – and and sending an email to me, and my friends from work.
add_action('wp_ajax_nopriv_submit_contact_form', 'submit_contact_form');
// Send information from the contact form
function submit_contact_form(){
// If there is a $_POST['email']...
if( isset($_POST['email']) && ($_POST['validation'] == true ) ) {
$email = $_POST['email'];
$email_to = "aaaa@example.pro";
$fullname = $_POST['fullname'];
$headers="From: ". $fullname .' <'. $email .'>' . "\r\n";
$group_emails = array(
'bbb@example.com',
'ccc@example.com',
'ddd@example.com',
'eee@example.pro',
'fff@example.pro'
);
$email_subject = "example intro: $email";
$message = $_POST['text'];
if(wp_mail($group_emails,$email_subject,$message,$headers)) {
echo json_encode(array("result"=>"complete"));
} else {
echo json_encode(array("result"=>"mail_error"));
var_dump($GLOBALS['phpmailer']->ErrorInfo);
}
wp_die();
}
}
I want to add to the headers 4 emails as BCC.
How do I do this right?
I tried a few variations of writing it without any success.