Skip to main content

Send emails with your SMTP server

Learn how to send emails using Retool Email.

If you have your own SMTP service, you can add it as resource to make it available in Retool apps and workflows. Once configured, you can send emails using your mail provider.

1. Create an SMTP resource

Follow the Connect to SMTP servers guide to add your SMTP service as a resource.

2. Create an app

If you haven't created an app yet, log in to Retool and click Create new -> App. Name the app and then click Create app.

3. Add a Form component

Drag a Form component to the canvas, then click Add components. Select Email from the list to add an email field to the form.

4. Create a query

Create a resource query and select your SMTP resource. Enter a valid email address in the From field. You can customize the sender name using the format "custom-name" Set the To field to {{email1.value}}. This passes the email address in the Email component to the query. Then, fill out the subject and body. You can optionally use Retool's AI feature to draft the body content. Make sure to save the query.

Write a query to send emails

5. Add an event handler

To send the email, you need to add an event handler to the Submit button. Select the button and then click + in the Event handlers section of the Inspector. The default settings should run the query you created, but make sure that:

  • Event is set to Submit.
  • Action is set to Control query.
  • Query is set to the query you created.

6. Test the form

To test the form, enter a valid email address and click the Submit button. If you don't see the email in your inbox, check your spam folder.

Add attachments to emails

Whether you use Retool Email or your own SMTP service, you can allow users to add attachments to the emails they send. To do this, add a File Button, File Dropzone, or File Input component to the canvas. Then in the query that sends the email, add the component in the Attachment(s) field. This allows users to upload an attachment using the app, and then automatically add it to the email.

You can also set the Attachment(s) field to the results of a Retool Storage query or any query returning a file object in Retool.