· core-java  · 2 min read

Set up a Custom Domain Email with Heroku Application

If your application is deployed in Heroku, Heroku server doesn’t provide email server by default.  In my previous post Deploying application on Heroku, I showed how to deploy a Spring Boot application in Heroku. Over to that, most applications use their custom domain and you will need email addresses with those domains for support or sales perspective.

So how do you set up custom email with your application domain? In this case, I needed to set up an email address info AT rentersvoices.com so people could contact me.

It’s a straightforward process and I will show in this post how to set up custom email.

Set up Custom Email in Heroku Application

Remember Heroku offers an option of CloudMailIn for custom email. It helps to receive incoming emails. In this post, we will not be using CloudMailIn with the restriction it has for free option in Heroku.

Instead, we are using forwardemail.net. There are few other options available like MailGun or SendGrid

To set up a custom email, you will need to add CNAME or MX records for your domain with your domain provider.

In my case, I was using NameCheap as my domain provider.

Add following MX records for your domain:

Type      Host     Value             Priority   TTL
MX Record @     mx1.forwardemail.net  10       60 min

MX Record @     mx2.forwardemail.net  20       60 min

Once we have configured MX records, we will need to configure TX records. This step is required so we can forward email coming to our custom domain to an email address of our choice.

Type          Host           Value                                     TTL
TXT Record     @         forward-email=abc@yahoo.com                  60 min
TXT Record     @         v=spf1 mx include:spf.forwardemail.net -all  60 min

After we add these records, we should wait till the cache is cleared for the domain. You might have to wait for an hour at max. Now try sending an email to custom address (in this case info AT rentersvoices.com) and you will receive that email at abc AT yahoo.com.

Conclusion

In this post, we showed how to set up an email in Heroku application. If you have any feedback, please feel free to post your comments below.

Back to Blog