Send multiple emails with slightly modified email bodies
-
I would like to have a contact form with a few checkboxes that will send different emails depending on which checkboxes are ticked.
I think I could use
wpcf7_before_send_mail
to modify the checkbox value to either leave it blank (no email would be sent to the second person) or update the value to the appropriate email address.add_action('wpcf7_before_send_mail', 'wpcf7_send_second_email'); function wpcf7_send_second_email($contact_form) { $data = $contact_form->posted_data; if ($data['checkbox'] == "second email") { $data['checkbox'] = [email protected]; } else { $data['checkbox'] = ""; } }
The part I can’t figure out is how to send more than two emails. I tried to hook into
wpcf7_add_meta_boxes
, but that didn’t work.add_action('wpcf7_add_meta_boxes', 'add_more_mail_boxes'); function add_more_mail_boxes($post_id) { add_meta_box( 'mail3div', __( 'Mail (3)', 'contact-form-7' ), 'wpcf7_mail_meta_box', null, 'mail_3', 'core', array( 'id' => 'wpcf7-mail-3', 'name' => 'mail_3', 'use' => __( 'Use mail (3)', 'contact-form-7' ) ) ); }
So this is definitely different from a CC or BCC.
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Send multiple emails with slightly modified email bodies’ is closed to new replies.