I am very confused with wp_mail(). Right here my code.
operate email_notification_for_admin_and_customer( $order_data ) {
$subject_email = 'Topic LOREM IPSUM';
$customer_email = 'Hello Buyer, Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque tempus, dui eget luctus accumsan, turpis orci malesuada turpis, eget volutpat ante velit a quam.';
$admin_email = 'Hello Admin, Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque tempus, dui eget luctus accumsan, turpis orci malesuada turpis, eget volutpat ante velit a quam.';
$send_email = array(
array(
'to' => 'email_1@instance.com',
'topic' => $subject_email,
'message' => $customer_email
),
array(
'to' => 'email_2@instance.com',
'topic' => $subject_email,
'message' => $admin_email
)
);
foreach ($send_email as $key => $worth) {
wp_mail( $worth['to'], $worth['subject'], $worth['message']);
}
}
I need to ship electronic mail notification to the admin and buyer, however wp_mail() solely sends first electronic mail, which is to buyer. Are you able to assist me. Thanks.
I’ve similar downside with this thread, however with completely different case.
UPDATE THE ANSWER
I am utilizing the wp_mail filter to format wordpress plain electronic mail into my html electronic mail template.
add_filter('wp_mail', 'my_wp_mail_filter');
operate my_wp_mail_filter($args) {
$message = $args['message'];
$args['message'] = wpet_email_template(apply_filters('wpet_filter_email', $message));
return $args;
}
That is the operate to incorporate html template.
operate wpet_email_template($message) {
// Render Template
ob_start();
embody('custom-email-template.php');
$wpet_template = ob_get_contents();
ob_end_clean();
// Substitute Placeholder
$message = str_replace('%%MAILCONTENT%%', $message, $wpet_template);
// Return Template with Information
return $message;
}
The issue is include_once(‘custom-email-template.php’);
then I alter to embody(‘custom-email-template.php’);
So that is the issue why the e-mail simply despatched to buyer electronic mail (first array of $send_email).
Right here the reply