Gmail Aliases: Free Domain Email With Postfix

Gmail Aliases: Free Domain Email With Postfix

Codeable.io

Gmail aliases let you send and receive email from your own domain without paying for Google Workspace. We run support@, hello@ and contact@ for our site this way, and the setup costs nothing beyond a VPS we already had. In this guide, you will install Postfix, point your DNS records at it, create a Gmail account, and add each address as one of your Gmail aliases.

The result is simple. Mail sent to your domain lands in one Gmail inbox. When you reply, the message leaves from your own address, not your Gmail one. So here is how we did it, step by step.

Why Gmail aliases beat a paid mailbox for a small site

Google Workspace charges every month for each mailbox. A small site rarely needs that. Most of us only want a few public addresses, one inbox to read, and replies that look professional.

Gmail aliases cover all three. You keep one free inbox, and your domain stays in your hands. However, you also take on the work of running a small mail server, so choose this route only if you are happy to maintain it.

What you need before you start

  • A VPS with a public IP address and root access.
  • A domain name that you control.
  • DNS that you can edit, such as Cloudflare or your own BIND server.
  • A new, free Gmail account.

Check one thing first. Some hosts block outgoing port 25, and Postfix needs it to hand mail to Gmail. Ask your provider before you begin, because a blocked port stops everything else.

Step 1: Install Postfix on your VPS

First, install Postfix. On Debian or Ubuntu, run the command below and choose Internet Site when the installer asks.

sudo apt update && sudo apt install postfix

Then open /etc/postfix/main.cf and add two lines. They tell Postfix to accept mail for your domain and to look up where each address goes. The Postfix virtual alias guide explains every option.

# Virtual domains
virtual_alias_domains = example.com
virtual_alias_maps = hash:/etc/postfix/virtual

Next, create the map in /etc/postfix/virtual. Each line sends one address to your Gmail inbox. The last line is a catch-all, so a mistyped address still reaches you.

hello@example.com     yourname@gmail.com
contact@example.com   yourname@gmail.com
support@example.com   yourname@gmail.com
@example.com          yourname@gmail.com

After that, build the lookup table, reload Postfix, and open port 25 in your firewall.

sudo postmap /etc/postfix/virtual
sudo systemctl reload postfix
sudo ufw allow 25/tcp

Because your domain is a virtual alias domain, Postfix never creates mailboxes. It forwards each message instead, so nothing piles up on the server.

Step 2: Set up DNS for your mail server

Mail servers find yours through DNS, so this step matters most. We use Cloudflare, but any DNS host works. Create these records, as the Cloudflare DNS guide describes:

  • An A record named mail that points to your VPS IP address. Set it to DNS only, because Cloudflare cannot proxy mail traffic.
  • An MX record for your domain that points to mail.example.com, with priority 10.
  • A TXT record for SPF that reads v=spf1 ip4:203.0.113.10 ~all, using your own IP address.
  • A TXT record named _dmarc that reads v=DMARC1; p=none; rua=mailto:hello@example.com.

Also ask your VPS provider to set a reverse DNS record that matches mail.example.com, because many receiving servers check it. The DMARC overview shows what the policy line does.

Prefer to run your own name server? Then BIND works too. Add the same records to your zone file, and raise the serial number each time you edit it.

$TTL 86400
@     IN SOA ns1.example.net. admin.example.com. ( 4 3600 1800 604800 7200 )
@     IN NS  ns1.example.net.
mail  IN A   203.0.113.10
@     IN MX  10 mail.example.com.
@     IN TXT "v=spf1 ip4:203.0.113.10 ~all"
_dmarc IN TXT "v=DMARC1; p=none; rua=mailto:hello@example.com"

Then wait a few minutes and test the records. Run dig MX example.com on your own computer, or use the free MXToolbox lookup. Both should show your mail server. If they do not, give DNS more time, because changes can take an hour to spread.

Step 3: Create a Gmail account for your aliases

Next, create a new Gmail account. Use a separate one, not your personal account, because every alias will send through it. Then turn on 2-Step Verification in your Google account.

After that, open the app passwords page and create a password named after your domain. Google shows it only once, so copy it somewhere safe. Never paste it into a chat or a public repository.

Step 4: Add your Gmail aliases

Now connect each address. Open Gmail, then Settings, See all settings, and Accounts and Import. Click Add another email address under Send mail as. Enter your name and the alias, for example support@example.com, and keep Treat as an alias ticked.

On the next screen, Gmail asks for an SMTP server. A free account has no Send through Gmail option, so type the details below. Do not use your own server here. Also type your Gmail address as the username, because Gmail rejects the alias.

  • SMTP server: smtp.gmail.com
  • Port: 587, with a secured connection using TLS
  • Username: your full Gmail address
  • Password: the app password from step 3

Gmail then sends a confirmation code to the alias. Postfix forwards it to your inbox, so copy the code and paste it in. Repeat the steps for every address. Finally, choose Reply from the same address the message was sent to. Google describes the screens in its send as help page.

Test your Gmail aliases and know the limits

Send a message to each address from another account, then reply to it. The From line should show your alias. Next, run a score check with Mail-Tester, and look at your records with our Domain Health Check, which reports SPF and DMARC.

Know the limits, though. A free Gmail account sends about 500 messages a day. Google also signs the mail itself, so some apps show the words via gmail.com. For that reason, keep your DMARC policy on none. If your volume grows, move to a mail service and keep the same DNS records.

If a message never arrives, read the mail log on your VPS with sudo tail -f /var/log/mail.log while you send a test. The log shows whether Postfix accepted the message and where it sent it. A refused connection usually means a closed port, and a deferred message usually means a blocked outgoing port 25.

Final thoughts

Gmail aliases give a small site professional addresses for the price of a VPS. Start with one address, test it, and then add the others. Your mail will keep arriving in one inbox, and your replies will carry your own domain.

Leave a Reply

Your email address will not be published. Required fields are marked *