NextDB.net Custom Email Triggers on Table Inserts and Updates

Introduction

NextDB.net has a new feature that allows you to configure custom email notifications for table inserts and updates. For each table, you can specify a custom email template for sending personalized emails. In conjunction with the NextDB.net Form Builder utilities, you can quickly add an HTML form to your web page to gather data and send email notices. This is ideal for RSVP, feedback forms, user registrations, and any other system where immediate email notification is essential. This system can be used to notify yourself as the owner/admin of the site, or for notifying your users.

Basics

On the admin pages there is a new option on each table panel. Click the 'Table Options' link on the table, then click open 'Email Notification Options', a blank textarea will appear. You can paste in the following simple example to test the system, just replace YOUR_EMAIL with your real email address, then do an insert to the table and you will immediately receive the notification:


        <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
        <TableMetaInf xmlns="http://nextdb.net/MetaInf">
        <Notifications>
            <Email to="YOUR_EMAIL" onInsert="true" from="info@nextdb.net">
            <Subject>test</Subject>
            <Body>test</Body>
        </Email>
        </Notifications>
        </TableMetaInf>
    
    


Binding dynamic values into the email

In most cases you will want to extract information from the insert/update to send in the email. Any data from the insert/update can be referenced in the XML template using the following format: ${column_name}. In this simple feedback example, bind variables are used in each element of the email. The values for each column represented in the ${column_name} syntax will be sent in the email.


        <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
        <TableMetaInf xmlns="http://nextdb.net/MetaInf">
        <Notifications>
            <Email to="${email}" onInsert="true" from="admin@ACME.com">
            <Subject>Thanks ${first_name} for your input!</Subject>
            <Body>
                ${first_name} ${last_name},
                Your feedback has been received and we will be in touch soon!

                Here is a copy of your feedback:

                ${feedback}

                Thanks,
                The ACME Team

            </Body>
        </Email>
        </Notifications>
        </TableMetaInf>

    


Activation Links

For systems that have a user registration process, you can force the user to verify their email address by sending them a link that they need to click to activate their account. This has become a standard process for most user registration systems. In this case, your table needs to have a column named 'ACTIVATION_STATUS' with a default value of something like 'PENDING', when the user gets the following email, it will have a link that once clicked will change the ACTIVATION_STATUS to 'ACTIVE'.


        <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
        <TableMetaInf xmlns="http://nextdb.net/MetaInf">
        <Notifications>
            <Email to="${email}" onInsert="true" from="admin@ACME.com">
            <Subject>Welcome to ACME.com!</Subject>
            <Body>

                Welcome ${first_name} ${last_name},

                You have successfully registered at ACME.com!
                
                    login: ${login}
                    password: ${password}

                Please click on this link to signup: ${ACTIVATION_LINK}

                Thanks,
                The ACME Team

            </Body>
        </Email>
        </Notifications>
        </TableMetaInf>