How to send bulk messages using wp mail function?
I was working in custom plugin development. I have created customer table in woocommerce and create form to reminder customer for new offers. I am using wp mail function to send multiple email to customer but its works with single customer mail.
here its my code
form class=formpopup action=# method=post
div
labelTo/labelinput id=customer_to_mail type=text class=modalform style=width: 70%; value= name=customer_to_mail required/divbr
divlabelSubject/labelinput class=modalform style=width: 70%; type=text name=customer_subject required/divbr
div class=descrlabelDescription/labeltextarea class=modalform style=width: 70%; height: 150px; name=customer_description required/textarea/divbr
input style=margin: 20px auto; display: flex; type=submit name=send-mail value=Send Email
?php
$to = array($_POST['customer_to_mail']); //[email protected]
$subject = $_POST['customer_subject'];
$body = $_POST['customer_description'];
$headers = array('Content-Type: text/html; charset=UTF-8');
wp_mail( $to, $subject, $body, $headers ); ?
/form
And Js code to automatic give customer email in to field
jQuery(document).ready(function() {
jQuery('.emlchk').click(function() {
var selectedEmailAddress = '';
jQuery('.emlchk:checked').each(function() { // $(':checkbox:checked')
jQuery('.checkbox_value').text(this.value + ' ');
var emailAdd = jQuery(#EmailAddressTD_+this.value+).text();
selectedEmailAddress = +selectedEmailAddress++emailAdd+;
});
jQuery(#customer_to_mail).val(selectedEmailAddress);
});
});