Batch mail, all recipients visible in “to” field
-
I am unable to get batch emails to iterate through all recipients. I get all emails in the to: field. Visible to all recipients.
Have tried these approaches:
1.
In functions.php added: add_filter( ‘wp_mail’, ‘mg_mutate_to_rcpt_vars’ );
and set $to_emails as an array like this:
wp_mail($to_emails, $subject, $content, $headers, $attachments);2.
$rcpt_vars = array();
$idx = 0;
foreach ($to_emails as $user_addr) {
$rcpt_vars[$user_addr] = array(“batch_msg_id” => $idx);
$idx++;
}
$rcpt_vars_json = json_encode($rcpt_vars);
$headers = array(
“Content-Type: text/html, charset=UTF-8”,
“X-Mailgun-Variables: ${rcpt_vars_json}”
);
$content = $content.’%recipient.batch_msg_id%’;
wp_mail($to_emails, $subject, $content, $headers, $attachments);
None of these works.I ended up with a foreach loop. Not optimal if I want to send 1000 emails with attachments.
foreach ($to_emails as $email) {
wp_mail($email, $subject, $content, $headers, $attachments);
}
- The topic ‘Batch mail, all recipients visible in “to” field’ is closed to new replies.