Skip to main content

Form Submitter's Email Address as the Reply-to Email

It's common to have email notifications for admins appear as if they are from the person who submitted the form. This allows for easy reply via email. However, this can result in the email being marked as spam or other issues, especially if SMTP is being used and the From email address needs to be set to a mailbox on the email server. The best practice is to use the Reply-to Email and Reply-to Name settings for the email notification template.

Instructions

1

Set up 'From Email' and 'From Name'

In your email notification template, add your site name and email address to the From Name and From Email settings, respectively. If you're using SMTP and/or a mail service, you'll need to ensure that the email address used exactly matches the email address configured for the Craft Email Settings. This might be something like noreply@mysite.com.

To ensure this email address is always correct, you can also specify Environmental Settings or access it via craft.app.projectConfig.

You might have something like this:


From Email

{{ craft.app.projectConfig.get('email.fromEmail') }}

From Name

{{ craft.app.projectConfig.get('email.fromName') }}
2

Set up 'Reply-to Email' and 'Reply-to Name' to match the Form Submitter

You can then put the form submitter's name and email address in the Reply-to Name and Reply-to Email settings. This means that when a site admin receives an email notification of a successful form submission, it'll appear to come from something like noreply@yoursite.com, but when they click the Reply button in their email client, it'll automatically reply to the form submitter's email address instead.

To grab the form submitter's name and email address, simply specify the field handles.

You might have something like this:


Reply-to Email

{{ email }}

Reply-to Name

{{ firstName }} {{ lastName }}
3

Save the Notification Template

Simply save the email notification template and you should be good.

Your template look something like this:

OR

Finished!

Please make sure your email and name field handles are correctly referenced. If not (or if it varies across forms), your email notifications may fail.