Creating an Email Notification

Last edit: Mar 20, 2020

This guide will help you create an Email Notification to send a welcome email to a newly signed up user.

Requirements

To follow the steps in this tutorial, you should understand the concept of notifications. You'll also use the sign-up form you created in a previous tutorial.

Steps

Creating an Email Notification is a two-step process:

Step 1: Create Email Notification

Create the notification file notifications/email_notifications/welcome_user.liquid:


---
to: '{{ form.email }}'
delay: 0
enabled: true
trigger_condition: true
from: 'Example Marketplace <info@example.com>'
reply_to: no-reply@example.com
cc:
bcc:
subject: 'Welcome {{ form.first_name }} in our marketplace!'
layout_path: mailer
---
<h1>Hi {{ form.first_name }}!</h1>

<p>Welcome in our marketplace!</p>

Step 2: Add notification to sign up form

Edit the forms/developer/sign_up.liquid file to associate this email with it. The email notification name is a path of the file relative to the email_notifications directory, without extension.

For notifications/email_notifications/welcome_user.liquid - the bolded part is the name (physical_file_path).

---
resource: User
email_notifications:
  - welcome_user
---

Now, when you submit the form, the newly registered user should receive the email.

Please note: if you are working on a staging environment, you also need to configure a test email, because we intercept all emails on staging to avoid spamming real users during tests.

Next steps

Congratulations! You have created an Email Notification. Now you can learn about using email layouts.

Questions?

We are always happy to help with any questions you may have.