0

I know this is already a common question, i tried to google it. but its not helping. i tried to play with the codes but still not working.

        <tr>
            <th><label>Admin Email: </label></th>
            <td><input type="text"  name="adminemail" value="<?php echo esc_html( empty($options['adminemail'])?'':$options['adminemail'] ); ?>" /></td>
        </tr>
        //----------------------//
        $admin_mail = empty($options['adminemail'])?'':$options['adminemail'];
        $headers = 'Content-type: text/html';
        $email_title = htmlspecialchars_decode( get_bloginfo(), ENT_QUOTES ) . " - New Booking Made" ;
       //---------------------//
        @wp_mail( $admin_mail, $email_title, $message, $headers );
  • forgot to add this is also on the script \\---------------------\\ foreach ( array( 'adminemail' ) as $option_name ) { if ( isset( $_POST[$option_name] ) ) { $options[$option_name] = sanitize_text_field( $_POST[$option_name] ); } } – Miguel Damayo Sep 28 '17 at 22:05
  • Please try to better define your problem, it´s not really clear what you have tried up till right now... – flomei Sep 29 '17 at 9:50
1

Ok even your question is difficult to read, here we go with I understand:

If you want to send one message to multiple email address you have more than one options but lets see two most used:

// FIRST
// One message to many addresses, this one is simplest, but every person will see each others email address
$tomail = 'mail1@gmail.com, mail2@gmail.com, mail3@gmail.com';
wp_mail( $tomail, $email_title, $message, $headers );

// SECOND
// One message per each email address
$email_array = array('mail1@gmail.com', 'mail2@gmail.com', 'mail3@gmail.com');
foreach ( $email_array as $tomail ) {
    wp_mail( $tomail, $email_title, $message, $headers );
}

The second one seems the proper approach to you, but you need to take into account the number of addresses to which you want to send because if they are too many you can have problems with your hosting, less than 50 I do not see problems maybe up to 100. But this is relative and depends on your server.

PS if you want to send as BC or BCC just or chance the FROM, you have to use the headers part

// For me is better as array, better control on it 
$headers = array(
    'From: bbb@example.com', 
    'CC: ccc@example.com', 
    'CC: ddd@example.com', 
    'BCC: eee@example.pro', 
    'BCC: fff@example.pro' 
);
wp_mail( $tomail, $email_title, $message, $headers );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.