The Trigger Email extension makes it easy to integrate your favorite SMTP provider with Firebase. Below I outline the steps needed to set up Mailgun to send emails from your Firebase applications. If you don't feel like doing this yourself or don't have the technical knowledge, feel free to contact me and let's chat about your requirements. You are also welcome to look at the other Firebase services I provide or a recent example of a Mailgun and Firebase project I completed for a client.
Mailgun provides you with a selection of four payment plans, Flex, Foundation, Growth, or Scale. The Flex trial should be sufficient to start with and give you a maximum of 5000 emails per month for three months, whereafter you only pay for what you send. So head over to the Mailgun website, click on the Get Started button and sign up for your brand new Mailgun account.
Once your Mailgun account has been created, activate your account by following the instructions in the activation email. Next, you need to add your custom domain.
Specify your domain and add the listed records to your DNS settings. Then, wait for the DNS records to propagate and click the Verify DNS settings button. Once Mailgun has verified your custom domain, you are ready to start with the Firebase Trigger Email extension setup.
I presume that you already have a Firebase account with a project set up. In your Firebase console, click on the Extensions link on the left of your screen, search for the Trigger Email extension and click on the Install button.
The Firebase team develops and maintains the Firebase Email Trigger extension, making it easy and reliable to integrate seamlessly with your favorite SMTP providers such as Mailgun, SendGrid, and MailChimp. On the installation screen, click on the Next button.
To use the Firebase Email Trigger extension, you need to upgrade your Firebase project to use the Blaze billing plan. If this is not yet the case, click on the Upgrade project to continue button and follow the instructions to set up your billing. Then, click on the Next button.
On the next screen, you'll be asked to configure a few settings, and this is where you'll connect the Firebase Email Trigger extension with your SMTP provider. You'll need to configure the following.
The cloud functions location is the region where you want to deploy the cloud functions that the Firebase Email Trigger extension would generate. You should select the area closest to that of your database and consult the Firebase location selection guide to make an informed decision. It's also crucial to understand that you can't reconfigure this setting once the extension is installed.
The SMTP connection URI is the data used by the Firebase Trigger Email extension to connect to your SMTP server. The URI should be in the form smtps://[username]:[password]@[hostname]:[port]. Your Mailgun SMTP credentials can be found in the Sending > Overview section of your custom domain.
The Firebase Trigger Email extension listens to the onCreate event of a user-specified document collection. The email document collection setting specifies the collection name that the extension will use to manage your emails. This value can be left as is or renamed to fit your purposes.
The email address the Firebase Trigger Email extension will send emails from.
The Firebase Trigger Email extension also has three optional settings, which is beyond the scope of this article. These settings can be left blank.
Then, click on the Install extension button and wait for the extension to be installed. The process should take 3 to 5 minutes.
To test the extension, create a new document in the email document collection configured during step 2. The document should have at least the following fields.
subject: 'Hello from Firebase!',
text: 'This is the plaintext section of the email body.',
html: 'This is the <code>HTML</code> section of the email body.',