It feels like forever since I wrote my last blog post on sending email via a vanity domain but has actually only been a year. In that post, I noted that sending via SendGrid was optional and it should all be doable using Google servers. The SendGrid config has been mostly ok, but hasn't been perfect and I wanted to remove this free third party from my email tool chain so I've revisited the setup and got it working through the Google mail server.
Will this work long term? Hopefully, but I'm not convinced for reasons I've laid out below. Let's do this.
Sending email
First I needed an app password for your Google account, which is a bit of a buried in the security interfaces. You can find the admin console for app passwords here.
This is also reachable by going to Google account settings, under "How you sign in to Google" select "2-Step Verification" and the option for App Passwords is at the bottom of the page.
Next, to configure gmail to send via the Google mail server, I needed to set the outgoing mail, found in:
Settings -> See all settings -> Accounts and import -> Send mail as
Then adding / editing my intended outgoing email address with these details on the second page ("Send emails through your SMTP server"):
SMTP server: smtp.gmail.com Port: 465 Username: Your google account (blah@gmail.com) Password: Your app password from earlier Secured connection using SSL ticked
Email security
This is a minefield and something I'm going to have to monitor to see how horribly I have broken things. First, this tool from Red Sift is great for analysing email security settings.
Deep breath...
SPF
To the DNS record, add:
include:_spf.google.com
and remove references to sendgrid to avoid too many lookups - this flags it as insecure.
DKIM
Without a full Google Workplace account, I can't upload a private key to Gmail so DKIM isn't going to work. Hopefully SPF will be enough. We'll see...
I think this also scuppers MTA-STS, but happy to be corrected.
DMARC
This is tricky. DMARC requires one of DKIM or SPF to pass tests properly in order to pass, then it suggest the receiving server takes a specified action (via the p
flag). In this case, my DKIM check is going to fail so that is out. The SPF check passes the initial test however there is a further check to make sure the Sender and From headers are the same. In my case they are not, since Sender is gmail and From is my domain so check fails with a no-alignment error - thus the DMARC check itself fails.
I've "solved" this by setting the p
flag in my DMARC DNS entry to "none" which just tells the receiving email server to deliver it anyway. It seems to work for my very limited testing sample, but obviously I'm not happy about this approach.
What is next?
I hope the SPF config will be enough to make my email work happily again, however I'm clearly hitting the limits of the free options in Gmail. If this doesn't work well enough, I think I'll move away from free options and look at something like AmazonSES which (from a quick read) will let me configure everything I need and charge me $0.10 per 1000 outgoing emails. This is probably the ultimate "correct" solution (unless I want to pay for a Google Workspace account) but is a lot more work and right now I don't wanna.
No comments:
Post a Comment