How to send bulk messages using wp mail function?
How to send bulk messages using wp mail function?
How to send bulk messages using wp mail function?
Yes, you can use an array of recipients: * @param string|array $to Array or comma-separated list of email addresses to send message. * @param string $subject Email subject * @param string $message Message contents * @param string|array $headers Optional. Additional headers. * @param string|array $attachments Optional. Files to attach. * @return bool Whether the email … Read more
If you want to send the email to more than one user, then you can write a loop. foreach ($employee_emails as $email) { wp_mail( $email, $subject, $message ); } This will loop through all the email addresses in the array and send the email to each one of them. UPDATE You can store your email … Read more
See the documentation: To set the “From:” email address to something other than the WordPress default sender, or to add “Cc:” and/or “Bcc:” recipients, you must use the $headers argument. $headers can be a string or an array, but it may be easiest to use in the array form. To use it, push a string … Read more
Try this: //after $wpdb->insert function $current_user = wp_get_current_user(); $current_mail = $current_user->user_email; //$user_email = $member_details->user_email; if($current_mail !== $_POST[‘user_email’] ){ // send mail only if different from the current_user email $subject = “Congrats! You are added to the Project – ” . “‘” . $project_title . “‘”; $message=”If you are not the member of project plz contact … Read more
These POST variables: $_POST[‘user_email’], $_POST[‘user_role’], and $_POST[‘status’] (which each is an array) are connected to each other by their index, hence you can loop through just one of them and use the same index (or iterator) to access the items in the other arrays. This should help you understand it: for ( $i = 0; … Read more
Perhpaps wp_mailwould be a suitable filter for this case as it is the first one to fire in wp_mail(). So perhaps something as simple as this might work, // For reference: // $atts = array( // ‘to’ => string, // ‘subject’ => string, // ‘message’ => string, // ‘headers’ => string or array (I think), … Read more
Depending on your setup and other specifics to your use case, you may want to clear any previous reply addresses. You can do this with $phpMailer->ClearReplyTos(). For example: add_action (‘phpmailer_init’, ‘my_phpmailer_example’); function my_phpmailer_example ($phpmailer) { $phpmailer->ClearReplyTos(); $phpmailer->addReplyTo(‘[email protected]’, ‘EXAMPLE’); } Also, if your example code in your question is exactly what you’re using, you need to … Read more
It sounds like you don’t have your code wrapped into an if statement that’ll check it only gets executed if the form was actually submitted, i.e. it gets run when you first view the page (GET) and again when you submit the form (POST). You can use the below snippet to ensure that the e-mail … Read more
You can directly query for users having a specific user_meta value. This will gain some performance over loading all the users first and then iterating over them and loading the meta_value afterwards. Have a look at the WP_User_Query class. If we are speaking of larger numbers of mails you may be better off to use … Read more