Sending automated receipt emails

Last updated on
30 April 2025

You may often wish to send an automated receipt message to users who fill in HubSpot forms on your site. HubSpot's form builder provides this feature automatically, but once you switch to Webform you can't use HubSpot's receipts -- only HubSpot's lead nurturing campaigns, which begin one business day after the lead is inserted.

Fortunately, the Webform module provides this functionality. Note that, by default, emails from Webform are sent in plain text only, but you can install the Mime Mail module to enable HTML mail functions.

When editing your form, head to the Webform tab and select the E-mails page. Here you can define who is emailed when the form is submitted. For example, suppose you want to email the user who submitted the form with a thank-you message. Here's how it works:

  1. Ensure the form asks for the user's email address, of course. When adding form components be sure to make one of type "E-mail", rather than making it a plain textfield.
  2. In the e-mails tab, select "Component value" and choose the email component from the form. Hit Add.
  3. Fill in the email header information and message content. Webform provides a number of tokens which will be replaced when the message is sent; for example, any instance of the token "%date" will be replaced with the date when the form is submitted. A complete list of token values is available under the email template field.
  4. Save the settings and test the form. The email will be sent automatically as soon as the form is submitted.

Of course, if you have a lead nurturing campaign set up with your form in HubSpot, the user will be enrolled in the automated email campaign automatically. (Remember that HubSpot will only recognize the submitted email address if the form key is "Email".)

Embedding tracking URLs

HubSpot provides tracking URLs so you can see where site visitors are coming from. By embedding these URLs in the receipt emails you send from Webform, you can track how many users visit your site from those emails, and determine the success rates of your marketing campaigns.

HubSpot provides a convenient tool to generate new tracking URLs. Visit Hubspot Reports Home and find the Tracking URL Builder tool. Simply fill in the details, including the landing page users will be directed to when clicking the link, and generate the URL. HubSpot will provide a link to copy into your emails.

Of course, this will work better if you've installed the Mime Mail module to enabled HTML email, but you can paste the link into plain-text messages if you'd like as well.

Adding the "Follow Me" module to emails

HubSpot's social media integration lets you specify various Facebook, Twitter and LinkedIn accounts used by your company, and links to them in the footer of every HubSpot automated email. If you want your social media accounts added to the footer of Webform messages, you can easily get the code from HubSpot.

Simply head to your HubSpot Social Settings page and select "Follow Me Module" on the left column. Check the Social Media icons you wish to embed icons for. The right column will contain a preview of the icon links. Click on 'embed code' link that contains the generated HTML code. Copy this code into the footer of your Webform emails -- though be sure you're using the Mime Mail module first to let Drupal send HTML messages.

Once the code is pasted into the email footer, it will be sent automatically with every Webform email. Be sure to update it if your company's social media accounts ever change.

Sending email to administrators

Sometimes you don't want to send an email to the user who filled out the form -- you want to email an administrator, a third-party service, or a sales or support guy. Webform supports sending as many automated emails as you need, fortunately enough.

In the Webform emails tab, simply add a new email to your chosen address. Webform will email everyone listed, so if you also want to email a receipt to the user, it can do both at once.

You might also wish to email different people depending on the value of a certain select field in the form. Make a "select option" field where the options' safe_keys are email addresses, and then in the email settings choose "component value" and select the name of your chosen form field. When the user selects an option, the email will be sent to the address in the safe_key.

Help improve this page

Page status: Not set

You can: