How to add autorespond mail in contact form 7
Contact Form 7 is a popular WordPress plugin for creating contact forms. To add an autorespond email in Contact Form 7, you can follow these steps:
Method 1: Using the "Additional Settings" field
- Go to your WordPress dashboard and navigate to the page where you have installed Contact Form 7.
- Click on the "Edit" button next to the form you want to add an autorespond email to.
- Scroll down to the "Additional Settings" field and click on the "Edit" button.
- In the "Additional Settings" field, add the following code:
on_sent_ok: "wp_mail('[email protected]', 'Subject', 'Autorespond message');"
Replace
[email protected]
with the email address you want to receive the autorespond email,Subject
with the subject of the email, andAutorespond message
with the message you want to send.
For example:
on_sent_ok: "wp_mail('[email protected]', 'Autorespond: Thank you for contacting us!', 'Thank you for contacting us. We will get back to you soon.');"
- Click "Save" to save the changes.
Method 2: Using a plugin
There are several plugins available that can help you add an autorespond email in Contact Form 7. One popular plugin is "Contact Form 7 Autoresponder".
- Install and activate the "Contact Form 7 Autoresponder" plugin.
- Go to the plugin's settings page and configure the autorespond email settings.
- In the "Contact Form 7" settings page, click on the "Autoresponder" tab.
- Select the form you want to add an autorespond email to and configure the autorespond email settings.
- Click "Save" to save the changes.
Method 3: Using a custom function
If you are comfortable with coding, you can also add an autorespond email using a custom function.
-
Create a new file in your WordPress theme's
functions.php
file and add the following code:function autorespond_email($form_id) { $form = wpcf7_get_form_by_id($form_id); $submission = WPCF7_Submission::get_instance(); $form_data = $submission->get_posted_data(); $email = $form_data['your-email-field']; $subject = 'Autorespond: Thank you for contacting us!'; $message = 'Thank you for contacting us. We will get back to you soon.'; wp_mail($email, $subject, $message); } add_action('wpcf7_mail_sent', 'autorespond_email');
Replace
your-email-field
with the name of the email field in your contact form. -
Save the changes and go to the Contact Form 7 settings page.
-
Click on the "Mail" tab and select the form you want to add an autorespond email to.
-
Click "Save" to save the changes.
That's it! With these methods, you should be able to add an autorespond email in Contact Form 7.