fbpx

How to Use SQL to Send Email for Free

SQL is a powerful, flexible tool to use for many purposes. When armed with the right tools, there are practically no limits to what you can do. In this post, we will show you how to use SQL to send email using one of our free tier engines.

In this use case, we will explore using the result of an SQL Query as a trigger to send an alert email. This is useful for verifying that data has been loaded and other validation checks. For example, maybe you want to be alerted when a new support request is generated or a new customer has signed up.

All you have to do is register for a Nom Nom Data account and follow the steps to install a Nominode.  Using the Nominode is free and no credit card is required. 

Three easy steps:

  1. Create an SMTP Connection with details about your SMTP server. Any SMTP server can be used.
  2. Create a Generic:Database Connection with details about your database. The information in the database will be used to determine if an e-mail is sent.
  3. Create a Task and select SQL Alerter from the list of engines.
    1. Use the Alias field to name your Task
    2. Select Send Email in the Action Type field
    3. Use the Target SMTP Server field to select the SMTP Connection that you created
    4. Fill out the From, To, Cc, Bcc, Subject and Body fields as desired
    5. Use the Target Database Connection field to select the Database Connection that you created
    6. Add an SQL Query that will determine if an e-mail will be sent. For example, SELECT COUNT(*) > 0 FROM users WHERE created >= NOW() -1 Day; The actual query line will depend on your database type and content. The example will return true when any new users have been created within 24 hours of when it is run. A true result triggers an email to be sent.
    7. Click the Create button

Now that you’ve created a Task to send an email based on an SQL Query result, you probably want to run it on a regular basis. Just create a new Sequence to do that. For this example, running the Task daily would make sense, but you can adjust the frequency to whatever you want.

You can test running your Task before it runs on schedule by running the Sequence manually. And that’s it, you have successfully used an SQL query to automatically trigger sending emails.

For more details, use the ? icons next to the fields in the Task or visit our SQL Alerter Engine support page.

Byte sized updates delivered to your inbox
  • This field is for validation purposes and should be left unchanged.