Great WordPress plugins allow other developers to easily hook into their functionality without modifying the original plugin's source code.

This is very important because any future plugin updates will override your changes

 

One of the hooks you'd want to hook into is wpcf7_mail_components filter. It receives 2 parameters that you can read and modify. The first one is an associative array with keys such as 'subject', 'body' (shown below), and a form obj. You must return the $mail_params array.

 

	add_filter( 'wpcf7_mail_components', 'app_100_handle_cf7_mail_components', 50, 2 );

	function app_100_handle_cf7_mail_components($mail_params, $form = null) {
		return $mail_params;
	}
	

The filter is located in: wp-content/plugins/contact-form-7/includes/classes.php

The $mail_params looks like this.

array (
	  'subject' => 'Test',
	  'sender' => ':)',
	  'body' => ':)

	--
	This e-mail was sent from a contact form on My Sandbox Site (http://orbutm.qsandbox.com)
	-----------------------------------------------------
	Orbisius UTM
	Total Visit(s): 3

	',
	  'recipient' => 'whatever_recipient@isconfigured.com',
	  'additional_headers' => '',
	  'attachments' => 
	  array (
	  ),
	)

	

the $form looks like this.

	WPCF7_ContactForm::__set_state(array(
	   'initial' => false,
	   'id' => 10,
	   'name' => 'contact-form-1',
	   'title' => 'Contact form 1',
	   'unit_tag' => NULL,
	   'responses_count' => 0,
	   'scanned_form_tags' => 
	  array (
		0 => 
		array (
		  'type' => 'text*',
		  'basetype' => 'text',
		  'name' => 'your-name',
		  'options' => 
		  array (
		  ),
		  'raw_values' => 
		  array (
		  ),
		  'values' => 
		  array (
		  ),
		  'pipes' => 
		  WPCF7_Pipes::__set_state(array(
			 'pipes' => 
			array (
			),
		  )),
		  'labels' => 
		  array (
		  ),
		  'attr' => '',
		  'content' => '',
		),
		1 => 
		array (
		  'type' => 'submit',
		  'basetype' => 'submit',
		  'name' => '',
		  'options' => 
		  array (
		  ),
		  'raw_values' => 
		  array (
			0 => 'Send',
		  ),
		  'values' => 
		  array (
			0 => 'Send',
		  ),
		  'pipes' => 
		  WPCF7_Pipes::__set_state(array(
			 'pipes' => 
			array (
			  0 => 
			  WPCF7_Pipe::__set_state(array(
				 'before' => 'Send',
				 'after' => 'Send',
			  )),
			),
		  )),
		  'labels' => 
		  array (
			0 => 'Send',
		  ),
		  'attr' => '',
		  'content' => '',
		),
	  ),
	   'posted_data' => 
	  array (
		'_wpcf7' => '10',
		'_wpcf7_version' => '3.8.1',
		'_wpcf7_locale' => 'en_US',
		'_wpcf7_unit_tag' => 'wpcf7-f10-p11-o1',
		'_wpnonce' => '09572933d3',
		'your-name' => ':)',
		'_wpcf7_is_ajax_call' => '1',
	  ),
	   'uploaded_files' => 
	  array (
	  ),
	   'skip_mail' => false,
	   'form' => '

Your Name (required)
[text* your-name]

[submit "Send"]

', 'mail' => array ( 'subject' => 'Test', 'sender' => '[your-name]', 'body' => '[your-name] -- This e-mail was sent from a contact form on My Sandbox Site (http://orbutm.qsandbox.com)', 'recipient' => 'whatever_recipient@isconfigured.com', 'additional_headers' => '', 'attachments' => '', 'use_html' => false, ), 'mail_2' => array ( 'active' => false, 'subject' => '[your-subject]', 'sender' => '[your-name] <[your-email]>', 'body' => 'Message Body: [your-message] -- This e-mail was sent from a contact form on My Sandbox Site (http://orbutm.qsandbox.com)', 'recipient' => '[your-email]', 'additional_headers' => '', 'attachments' => '', 'use_html' => false, ), 'messages' => array ( 'mail_sent_ok' => 'Your message was sent successfully. Thanks.', 'mail_sent_ng' => 'Failed to send your message. Please try later or contact the administrator by another method.', 'validation_error' => 'Validation errors occurred. Please confirm the fields and submit it again.', 'spam' => 'Failed to send your message. Please try later or contact the administrator by another method.', 'accept_terms' => 'Please accept the terms to proceed.', 'invalid_required' => 'Please fill the required field.', 'captcha_not_match' => 'Your entered code is incorrect.', 'invalid_number' => 'Number format seems invalid.', 'number_too_small' => 'This number is too small.', 'number_too_large' => 'This number is too large.', 'invalid_email' => 'Email address seems invalid.', 'invalid_url' => 'URL seems invalid.', 'invalid_tel' => 'Telephone number seems invalid.', 'quiz_answer_not_correct' => 'Your answer is not correct.', 'invalid_date' => 'Date format seems invalid.', 'date_too_early' => 'This date is too early.', 'date_too_late' => 'This date is too late.', 'upload_failed' => 'Failed to upload file.', 'upload_file_type_invalid' => 'This file type is not allowed.', 'upload_file_too_large' => 'This file is too large.', 'upload_failed_php_error' => 'Failed to upload file. Error occurred.', ), 'additional_settings' => '', 'locale' => 'en_US', 'mail_template_in_process' => array ( 'subject' => 'Test', 'sender' => '[your-name]', 'body' => '[your-name] -- This e-mail was sent from a contact form on My Sandbox Site (http://orbutm.qsandbox.com)', 'recipient' => 'whatever_recipient@isconfigured.com', 'additional_headers' => '', 'attachments' => '', 'use_html' => false, 'name' => 'mail', ), ))

Feel free to use the first array and modify its contents.

Disclaimer: The content in this post is for educational purposes only. Always remember to take a backup before doing any of the suggested steps just to be on the safe side.
Referral Note: When you purchase through an referral link (if any) on this page, we may earn a commission.
If you're feeling thankful, you can buy me a coffee or a beer