Chapter 5:
Send Emails

We’ll use the Email Service to send you an email each time someone leaves feedback.

Step 1: Add the Email Service

Let’s start by adding the Email Service to our app. Select the blue ‘+’ button in the sidebar menu to open the list of available services. Then, click on the ‘Email’.

Adding a service

Add a service

Adding the Email Service

Select the Email Service

Now you’ve enabled the Email Service, it’s just one line of Python to send an email.

Step 2: Call the send function

Go to your Server Module, and modify your add_feedback function to look like this. Remember to change the address to your email address! We added this function in Chapter 3.

def add_feedback(name, email, feedback):
  # Send yourself an email each time feedback is submitted"", # Change this to your email address!
                   subject=f"Feedback from {name}",
  A new person has filled out the feedback form!

  Name: {name}
  Email address: {email}

Step 3: Publish your app

You can easily publish you app online for anyone to use. Click the ‘Publish’ button at the top right of the editor, then select ‘Publish this app’ and use the public URL provided or enter your own.

Publishing an app and changing its URL

Publishing an app and changing its URL

Fill in a name, email address, and some feedback and click Submit. You’ll receive an email letting you know someone has filled out your feedback form.

Using the deployed app

Using the deployed app

And that’s it. You’ve just built a working database-backed feedback app in Anvil.

You can also use the following link to clone the finished app and explore it yourself:

In the next section, you can challenge yourself to reinforce what you’ve learnt and learn more!

If you’d rather not try the challenge, check out the below section to see what’s next.

What next?

Head to the Anvil Learning Centre for more tutorials, or head to our examples page to see how to build some complex apps in Anvil.

Chapter complete


Congratulations! You’ve built and shipped a database-backed web application!

You also now have a solid foundation in Anvil.

Your app is already live on the internet. Go to Publish App in the Gear Menu gear icon for details.

What next?

Head to the Anvil Learning Centre for more tutorials, or head to our examples page to learn how to build more complex apps in Anvil.