So far sending massive emails its fine using Bcc
foreach ($users as $key => $user) {
if ($user->roles[0] != "administrator") {
$headers[] = 'Bcc: ' . $user->user_email;
}
}
wp_mail("noreply@test.com", $subject, $message, $headers);
The problem is that emails have variables, like Hello, {{user_name}}
BUT i dont know how to replace them for each user without putting wp_mail function inside the foreach loop, since Bcc its the best approach
Currently the way I am replacing the variables when sending emails to single users, its this way
$message = str_replace(
['{{user_name}}'],
[$user->user_login],
$message
);
so what i am asking its a way of replacing the variables specially when its massive emails