Using Gmail With A Custom Domain

An email address functions as a proof of identity in today’s online world, and losing access to your email can be devastating. The most common email provider today is Gmail, but the problem with Gmail is that it’s tied to your Google account, along with all other Google products. If you break the terms of service in any of them, you can lose access to your whole Google account, including email, for good.

The easiest solution is to get a custom email domain. With some careful setup, you can hand out a custom address (such as scott[@]sdubinsky.com), send as that address, and continue to work from the comfort of Gmail. Infinite custom emails, from your domain, for free.

Forwarding To Gmail

Your domain registrar offers a free email forwarding service. Set it so that all emails (*@yourdomain.com) forward to your actual Gmail address. Do this before you enable Cloudflare, if you use that.

If you do use Cloudflare, you’ll need to add additional MX records to forward emails to your registrar’s email servers, so they know in turn to forward it to your Gmail account. Look through your registrars docs to find out what address those servers are listening at.

At this point you can give people the new email address you want to use, or custom addresses for each service you sign up for, or whatever you want to do. I use a custom email for each random thing I sign up for, so I can see who sells addresses to spammers.

Sending As

You can also set up your Gmail account to send as a specific custom email address. For example, I have scott[@]sdubinsky.com set up as an address I send as, to keep it consistent with what people see from me.

Presumably you have 2FA(two-factor authentication) enabled for your Google account. If not, go do that now, it’ll save you a lot of heartache in the future.

Now that you have 2FA, you can’t do SMTP (Simple Mail Transport Protocol, the protocol for sending email) signins with 2FA, because it happens automatically. To get around this, you generate an app-specific password. This limits the damage that password can do if it gets out, making 2FA less important. To generate one, go to myaccount.google.com and search for app-specific password. Google being Google, I can’t tell you where it is because the location keeps changing. Generate a password, and write it down somewhere.

Next, go to Gmail -> settings -> see all settings -> accounts and import -> send mail as -> add account. Enter the email address you want to send as. It’ll pop up a yellow form. Enter your Gmail username and the app-specific password you generated earlier. Leave “set as alias” checked. Change the SMTP address to smtp.Gmail.com. Then it’ll send you a confirmation email to show you actually have access to that address. Click the link in the email, and you’re done! At this point you can erase or throw away the app-specific password, you won’t need it anymore. There’s also a switch at the bottom of the accounts list for “reply from the same address the message was sent to.” You’ll have to repeat these steps for each email alias you want to use, but you can generate as many app-specific passwords as you need.

And that’s it! Tell your DNS provider to forward all mail to your registrar, tell your registrar to forward all mail to your Gmail account, and tell your Gmail account to send mail as your custom domain. Nobody needs to know it’s backed by Gmail, and if you lose access to your Gmail account you can simply start forwarding to a different provider without missing anything.

Want more? Subscribe via RSS. Want to talk about cleaning up your codebase? Email me! Otherwise, happy coding!
Originally published on December 15, 2023.