sending mails with wp_mail() to multiple recipients using wp_cron and dynamic email body data

I have a frontend submission form, where users can add events to a custom post type. I want to send an email to each user 1 week before this event takes place.

The emails are sent via wp_cron. The function is called with a hook. Its working correctly, but i want to add custom values to the email body.

With my code its not possible to add dynamic value to the body template of my email.

With this function below, i loop through the events post type and get the required data

function leweb_get_events_detail() {      // Query     global $  wp_query;      // Arguments       $  args = array(         'post_type' => 'events',     );      // Start the Query     $  query = new WP_Query( $  args );      // The Loop     if( $  query->have_posts() ) {          $  results = array();          while( $  query->have_posts() ) {              $  query->the_post();                           $  event_date_timestamp = get_post_meta( get_the_ID(), 'event_date_timestamp', true );             $  future_timestamp = strtotime("+1 week");              // Damit wird geprüft ob schon einmal diese Email gesendet wurde             $  notification = get_post_meta( get_the_ID(), 'event_creator_notification' );              if( !in_array( '1week', $  notification )  && $  event_date_timestamp < $  future_timestamp ) {                  $  event_id = get_the_ID();                 $  event_email = get_post_meta( get_the_ID(), 'event_email', true );                  $  results[] = array(                                  'event_id'      => $  event_id,                                  'event_date_timestamp' => $  event_date_timestamp,                                 'event_email'     => $  event_email,                 );              }         }          return $  results;      }      wp_reset_query();  } 

The function below lets me fetch data from the post_meta array

function leweb_get_values_from_post_meta( $  meta = '') {      $  results = leweb_get_events_detail();      $  values = array();     foreach( $  results as $  key => $  value ){          $  values[] = $  value[ $  meta ];      }      return $  values; } 

The function below is called from wp_cron. The email is sent to all recipients who match the above conditions and a value is added to the post meta, to prevent multiple sends of this email.

function leweb_send_mail_to_author() {       // Alle Emails aus dem Array auslesen und für das BCC Feld im Email Header vorbereiten     $  emails = leweb_get_values_from_post_meta( 'event_email');      if ( !empty( $  emails ) ) {          $  emails = 'BCC: ' . implode( ',', $  emails );          // Email senden         $  to = '';         $  subject = 'Dein Event findet bald statt!';         $  body = file_get_contents( get_stylesheet_directory() . '/templates/email/event-creator-notification.php');         $  headers = array( 'Content-Type: text/html; charset=UTF-8','From: Example <>', $  emails );          wp_mail( $  to, $  subject, $  body, $  headers );          // Wert in post_meta eintragen um die Mehrfachsendung zu verhindern         $  post_id = leweb_get_values_from_post_meta( 'event_id');          foreach( $  post_id as $  id ) {              add_post_meta( $  id, 'event_creator_notification', '1week' );          }      }  } 

After i coded this i figured out, its not possible to send dynamic content in the body of my email. The only way to achieve this, is to call the wp_mail() in foreach. But this would be heavy i think? Its possible that this job sends up to hundred emails per run in the future…

So i was wondering if there is another way to do this clean?

Thanks for your opinions, i know its a bit complex, but i dont have any other ideas…

How to automatically obtain keys in Evolution for e-mail recipients? (key discovery)

I am using the PIM Evolution 3.22.6 for e-mail and contacts. For encrypting e-mails gpg (GnuPG 2.1.18) is used by Evolution.

How can I configure my system such as when I compose an e-mail the PGP key for the recipients are automatically retrieved from key servers and added to my keyring?

For example when I try to send an e-mail to a recipient, which is not in my keyring I get the following error message: gpg: <>: skipped: No public key

In case I run – outside of Evolution – gpg --search-keys a key is successfully found. Is there any way to tell Evolution to deal with the search?

Can’t send sms to short code recipients like 567676,56161 etc. From galaxy note 8

The message I get is “Failed to send message. Review and send again”. I’ve tried entering the correct smsc number, allowing premium access , nothing has worked.

I’m able to send sms to normal phone numbers.

Ps: I tried the sim in another phone., I couldn’t send it from there too.

Limit number of recipients in To: and CC: on emails outgoing with ASSP

Too many Mail Service Providers, such Hotmail, Google, has limitations about number os sender into To: CC: and BCC: headers of mail messages.

I’m not finding a possible configuration, in ASSP.

The closest, but not 100%, with this situation, would be, LocalFrequencyInt and LocalFrequencyNumRcpt located in the documentation itself

Is there another way to block this unhealthy practice of putting hundreds of emails in the To: field?

How can i recieve multiple recipients messages; in the group message, instead of downloading individually before opening in group?

I was added in group message, yet i recieve single message from each person. How can i recieve all recipients in just the group message? Why do i have to download then first before going to group message, just to read it there?. Should my character encoding be on auto or default alphabet?

In Gmail, how can recipients be moved back and forth between the To and CC fields?

In the Gmail web interface, when composing a message, is there an easy way to move recipients that are already entered in the To and CC fields back and forth between those fields?

I’m looking for a better way to do this than manually cut-and-pasting the text representing the recipients back and forth between those fields, making sure all comma separators are correctly in place.

Example scenario where this would be useful:

  1. User Alice sends out a message to Bob, Chris, Dave, and me asking for opinions on a topic.
  2. Bob does a “reply all” with his opinion.
  3. Now I start composing a “reply all” to Bob’s message to continue the thread with my opinion. At this point, Bob is in the To field, and Alice and the other recipients are in the CC field. My message is primarily for Alice (since she sent out the original message with the request for comments), so I want to move Bob to the CC field, Alice to the To field, and leave the other recipients where they are, before I send my message.