I am sending mails via wp_mail
inside a foreach
loop.
It works fine but after 20 minutes or so the mails are sent again?
This is my function (I am running it on save product variation of WooCommerce):
add_action( 'woocommerce_save_product_variation', 'bbloomer_save_custom_field_variations', 10, 2 );
function bbloomer_save_custom_field_variations( $variation_id, $i ) {
$arrayEmails = array(
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
'[email protected]',
)
$headers[] = 'From: Mail sender <[email protected]>';
foreach($arrayEmails as $email) {
wp_mail( $email, 'Mail subject', '<p>This is the mail content</p>', $headers );
}
die();
}
I receive the mail 5 times which is correct. But later I receive the mails again?