TLDR Summary
- Use SMTP Host: smtp-relay.gmail.com
- Use SMTP Port: 465
- Have 2fa enabled
- Generate and use an app password
- Use your admin account to authenticate with the above
I generally use Supabase to build with. I like that they provide excellent, accessible Postgres deployments plus authentication for just about every flavor that you can think of. It's the end of September 2024, and they have announced some changes to what is allowed with regards to sending emails via their platform. Basically, they are requiring everyone to use their own SMTP relays instead of Supabase's. I suppose that's reasonable.
For Vewrite, a technical writing project management service that I've been building, I have set up my deployment on Netlify, and rely on Google Workspace for our org's email, shared drives, and internal docs. There is a support email which I'd like to use for Vewrite, and I suppose it makes sense to rely on Google's outgoing SMTP relay for Supabase, too.
It was a bit finicky to set up and I ran into a couple of gotchas before getting it all to work correctly. In the name of **science!**, I'm sharing how to set this up below.
You'll need to have:
- A Supabase account
- A Google Workspace account
Google Workspace Account
For the Google account, you'll be managing the account settings via the Google Security section of your account. After you've signed in, you can access this from the dropdown that is in the top-right on a Google-related page (like Gmail, etc.), then "Manage your Google Account", and finally the Security tab on the left nav bar.
You'll need to have a few things set up:
- Access to the Google Admin Console
- 2fa enabled for the admin account
- A generated Google app password for Supabase
For the first one, if you're the administrator, you're good to go. If not, you'll have to work with them to gain access.
For 2fa, you must set this up. I highly recommend doing so with Google Authenticator. Just to be super clear: this step is not optional. You will not be able to generate app passwords without this. Setting up 2fa is done via the Security tab. Scroll down until you see "2-step verification".
Lastly, you'll need to generate an app password. For whatever strange reason, this option is no longer exposed for me, but is available via the search bar. Type in "app password" in the search bar if you can't find it in the security panel.
Once you click on the app passwords option in the search bar, you'll be asked to reauthenticate, and then passed on to the generation section. Simply give it a name, and copy the password somewhere locally. You'll need this for Supabase.
Supabase Setup
For the Supabase account, you'll be managing the outgoing emails via the Auth Settings page. Supabase has decent docs, and you can see what we're going to be working with here.
If you're already in your Supabase project, go to "Project Settings", and then "Authentication", within the "Configuration" section. Then, scroll down to "SMTP Provider Settings".
To get everything working, you'll need to set up the Google's SMTP relay in Supabase. You'll need to have the following information:
- SMTP Host: smtp-relay.gmail.com
- SMTP Port: 465
- SMTP Username for the admin account (it's an email address)
- Generated google app password
Fill in the fields, and you should be good to go. You can test the connection by sending a test email from the Supabase dashboard.
That's it! You should be all set up to send emails from Supabase via Google's SMTP relay.