Title: Parse mail tags programmatically
Last modified: November 15, 2021

---

# Parse mail tags programmatically

 *  [mikeknappe](https://wordpress.org/support/users/mikeknappe/)
 * (@mikeknappe)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/parse-mail-programmatically/)
 * Hi all,
 * I want to parse (and maybe send) a mail with the content of a CF7 mail programmatically
   after a form was submitted.
 * I have this so far:
 *     ```
       $submitId = '13659';
       $formData = get_post_meta( $submitId, 'data', true ); //get submitted data
       $form_id = '1267';
       $wpcf7 = WPCF7_ContactForm::get_instance( $form_id ); //get the form
       if( $wpcf7 )
       {
       	$props = $wpcf7->get_properties(); //get all props. from the form
       	$dataArr = json_decode( $formData, true );
       	if( $props['mail']['active'] ) //check if mail is active
       	{
       		//do the magic on the body part with the submitted content
       		//something like:
       		//$props['mail']['body'] = wpcf7_parse_tags( $props['mail']['body'], $dataArr );
       	}
       }
       ```
   
 * I mean, I could use 3 x foreach to replace all tags, but there will be tags missing
   like [_site_admin_email], [_site_title], …
 * Maybe someone has done something similar so far and can help me a bit or give
   me a hint.

Viewing 1 replies (of 1 total)

 *  Thread Starter [mikeknappe](https://wordpress.org/support/users/mikeknappe/)
 * (@mikeknappe)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/parse-mail-programmatically/#post-15071137)
 * As far as I’ve read the code corretly, there is some function doing this:
 * `wpcf7_mail_replace_tags`
    [https://github.com/wp-plugins/contact-form-7/blob/721fd1d81ff871d359f61131f34307970795b412/includes/mail.php#L131](https://github.com/wp-plugins/contact-form-7/blob/721fd1d81ff871d359f61131f34307970795b412/includes/mail.php#L131)
 * Problem here, after some investigation. It’s using live posted data from a form:
 *     ```
       $submission = WPCF7_Submission::get_instance();
       $submitted = $submission ? $submission->get_posted_data( $tagname ) : null;
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Parse mail tags programmatically’ is closed to new replies.

 * ![](https://ps.w.org/contact-form-7/assets/icon.svg?rev=2339255)
 * [Contact Form 7](https://wordpress.org/plugins/contact-form-7/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/contact-form-7/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/contact-form-7/)
 * [Active Topics](https://wordpress.org/support/plugin/contact-form-7/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/contact-form-7/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/contact-form-7/reviews/)

 * 1 reply
 * 1 participant
 * Last reply from: [mikeknappe](https://wordpress.org/support/users/mikeknappe/)
 * Last activity: [4 years, 5 months ago](https://wordpress.org/support/topic/parse-mail-programmatically/#post-15071137)
 * Status: not resolved