How to setup a custom domain for your Gmail address
We’ve all seen the comics about what your email address says about you, right? If not, let me refresh your memory:
So you are already at the second-from-the-top level with your Gmail address. But how do you level up to using your own domain, as cheaply as possible? Read on!
Goals
Here are the goals for this article:
- Continue to use your @gmail.com email account, but use a custom domain name that forwards all email to your Gmail account, e.g. me@customdomain.com
- Have outgoing email look like it was truly sent from your domain, not forwarded via Gmail
- Do this as cheaply as possible (i.e. only the cost of the domain name)
1. Register or transfer your custom domain with Google Domains
The secret to all of this is that Google Domains includes the email forwarding functionality with the cost of the domain. Previously, I had been paying Pobox.com $20/year (USD) for this service. Google Domains charges $15/year (USD) for the domain, with no extra costs necessary.
If you are registering a new domain, it’s fairly straightforward to do. If you are transferring an existing domain, the instructions vary based on your current registrar. Here are Google’s instructions for transferring. A few things to keep in mind:
- There is generally no cost to transfer, other than paying Google for an additional year of service. This will extend the registration of your domain for an additional year beyond its current expiration point.
- You can’t transfer within the first 60 days of having bought/transferred a domain.
- You’ll need to unlock the domain at your existing registrar.
- You often need to turn off WHOIS privacy temporarily during the transfer process.
- Your old registrar may send you an email to get your explicit approval for the transfer before it can go through.
2. Set up email forwarding
Once the domain has been successfully transferred to Google Domains, we are ready to set up email forwarding.
- Log in to Google Domains
- Click the Email icon for your custom domain
- Enter the email address at your custom domain you’d like to forward to your Gmail account, e.g. “info” for “info@customdomain.com”. Alternatively, you can use a wildcard (*) to forward anything sent to your custom domain to your Gmail account.
I’ve chosen to use a wildcard here because it’s very flexible. It lets me do things like use a throwaway account like hot.new.startup@customdomain.com to register for a service, and then I can filter email sent to that address into the trash if it starts getting spammed.
This will automatically set up MX records for your domain so that email gets forwarded. Note: This assumes you aren’t already using MX records for some other purpose (Pobox, Google Apps/G Suite, etc). If you are, you’ll want to delete those records.
At this point, you can receive any email sent to your custom domain. Great! However, you probably want to send email from your custom domain as well.
3. Set up mailgun.com account for outbound emails
It’s possible to use Gmail’s SMTP servers to send outbound email but it has undesirable side effects. If you do this, the sender will see a “via gmail.com” label. Here’s what it looks like if the recipient is using Gmail:
This really shatters the illusion that you are “skilled and capable”, in the words of The Oatmeal. We can do better than that! We will use the free service tier of Mailgun.com, which allows us to send 10,000 outbound emails a month for free (as of May 2018). I don’t know about you, but that covers my monthly email needs.
- Sign up for a new Mailgun account at https://signup.mailgun.com. You don’t need to enter payment details.
- Verify your account (both verification email and SMS code)
- Click Domains and then the Add New Domain button
4. Enter your custom domain. Despite the warning, I entered my naked domain without a subdomain:
You’ll see a page like this. Next you need to enter some DNS settings on Google Domains. This will kill two birds with one stone — proving to Mailgun that you own the domain, and setting up the SPF & DKIM records used to validate email sent through your domain.
Note: SPF & DKIM records are used to verify the email that was sent from your domain really came from you and isn’t being spoofed by a spammer. They are required by Mailgun, but this is the main reason we are using Mailgun in the first place. :)
5. Add the SPF record. On Google Domains, click the DNS icon. Scroll down to “Custom resource records” at the bottom.
Enter the settings found on Mailgun like so, then click Add.
Note that Google Domains is one of the registrars that wants you to use an @ sign instead of entering customdomain.com.
6. Add the DKIM record. Use the key shown on Mailgun like so, then click Add.
Because of the note mentioned above, you will enter krs._domainkey. Alternatively, you can enter krs._domainkey.customdomain.com and Google Domains will automatically replace it.
7. Wait for these DNS records to propagate. This could take up to 24 hours, but typically will only take 5–10 minutes. Once it has propagated, you will see green checkmarks in Mailgun under Domain Verification and DNS, like so:
Note: We don’t want to enter MX records because we won’t be receiving email via Mailgun. Entering MX records could conflict with the automatic MX records that Google Domains sets up for Email Forwarding. Also, we don’t need to enter the optional CNAME record for email because we aren’t planning to use Mailgun for mailing list purposes.
8. Lastly, obtain your SMTP Credentials from the top of the Mailgun Domains entry:
You will need these for the next step:
SMTP Hostname: smtp.mailgun.com
Username: <Default SMTP Login>
Password: <Default Pasword>
If desired, you can set up a custom username/password using the Manage SMTP Credentials link, but the defaults will work fine.
Now that we’ve set up Mailgun,we will configure Gmail to use the SMTP server to be able to send from our domain.
4. Set up Gmail to be able to send from your custom domain
- In Gmail, click the gear icon on the right-hand side.
2. Click “Accounts and Import” (or “Accounts” if you are using the old Gmail interface), and scroll down to “Send mail as:”.
You probably want the setting for “Reply from the same address the message was sent to” so that if you reply to any email sent to me@customdomain.com, the reply will automatically be sent from that same addresss.
3. Click “Add another email address”
Enter the email address you want to use at your custom domain, e.g. me@customdomain.com
You can read up on the “Treat as alias” setting, but generally you’ll want it enabled. That will mean that mail sent to either address (@customdomain.com or @gmail.com) will go to the same inbox. When you send email, you pick which domain to send from.
4. Click “Next Step >>”. Enter the SMTP Credentials you noted from Mailgun. Choose port 587.
5. Click “Add Account >>”
Gmail will verify these settings are correct.
5. All done! You can send and receive email at your custom domain.
In Gmail, you will see your me@customdomain.com email address as an option in the From drop down:
When receiving an email from your custom domain, we can verify that everything is working smoothly. (You may need to send this to a different email address to properly verify, as opposed to sending it to your Gmail account.)
A few things you’ll notice:
- No more “via gmail.com”
- It shows mailed-by and signed-by customdomain.com instead of gmail.com
- If you use the “Show original” option in Gmail, you’ll see that SPF and DKIM both PASS. This is this gold standard for email.
Note for advanced users
I haven’t created DMARC records because Google recommends doing so only if all email gets sent through your own domain. I use apps like Outlook for iOS that can end up sending through Gmail’s SMTP servers so it could do more harm than good.
Mobile app support
To send email through a custom domain, I’ll show you a few options on iOS. Hopefully should be able to Google this to figure it out on Android.
Gmail app
This one is easy, it works out of the box. Just tap the From: and select your custom me@customdomain.com address:
Outlook for iOS
Open Settings, then your Gmail account, then tap Advanced Settings, then Add Alias. Enter your custom me@customdomain.com alias. You can also set it to be the default if you prefer.
Caveat: Outlook still sends outgoing mail through the Gmail SMTP servers, so it doesn’t appear 100% legitimate on the senders end. It doesn’t know how to use the SMTP servers configured on Gmail.
Mail app for iOS
This is a tricky one, and I’m not 100% happy with the solution. This post and this article inspired me.
Instructions:
- If you still want to be able to send from your Gmail account, set up a Gmail account on your iPhone as usual. ( iOS > Settings app > Accounts & Passwords > Add Account > Google)
- For the me@customdomain.com email address, under iOS > Settings app > Accounts & Passwords, tap Add Account. Tap Other. Then tap Add Mail Account.
- Enter your custom email address and password for your normal Gmail account. (You may need an app-specific password if using two-factor authentication). Tap Next.
- The automatic configuration will not work, so you’ll get a chance to enter in custom options:
Incoming Mail Server
Host Name: imap.gmail.com:993
Username: Your Gmail address
Password: Your Gmail password (or an app-specific password if using two-factor authentication)
Outgoing Mail Server
- The same credentials that we received from Mailgun
This should allow you to send email from either account. However, it seems like it probably fetches two copies of all of your email, even though it thankfully only displays one copy in the unified inbox. The custom domain option is using IMAP, which I’m not sure if the Google account one is using or not. Please let me know if you find a better solution! Discovering my email address is left as an exercise for the reader. ;)
Gmail Labels for your custom domain emails
Tip: Set up a label and an automatic filter so that any email sent to your custom domain will automatically get flagged as such so it’s easy to tell at a glance. Here’s how:
- Send yourself an email to your custom domain
- In the Gmail search, enter @customdomain.com and click the down arrow
3. Change the filter to be To: @customdomain.com (instead of Has the words). Click “Create filter”
4. Click Apply the label: and on the drop down, choose New label… and create one called “@customdomain.com” (entering your custom domain of course)
You can click “Also apply filter to N matching conversations” to tag the existing email you sent yourself.
5. Click Create filter. Now your incoming mail can be filtered like this. (I also changed the color of the label):
I hope you enjoyed this odyssey to becoming skilled and capable!