apps/docs/content/guides/auth/auth-smtp.mdx
If you're using Supabase Auth with the following configuration:
You will need to set up a custom SMTP server to handle the delivery of messages to your users.
To get you started and let you explore and set up email message templates for your application, Supabase provides a simple SMTP server for all projects. This server imposes a few important restrictions and is not meant for production use.
Send messages only to pre-authorized addresses.
Unless you configure a custom SMTP server for your project, Supabase Auth will refuse to deliver messages to addresses that are not part of the project's team. You can manage this in the Team tab of the organization's settings.
For example, if your project's organization has these member accounts [email protected], [email protected] and [email protected] then Supabase Auth will only send messages to these addresses. All other addresses will fail with the error message Email address not authorized.
Significant rate-limits that can change over time.
To maintain the health and reputation of the default SMTP sending service, the number of messages your project can send is limited and can change without notice. Currently this value is set to <SharedData data="config">auth.rate_limits.email.inbuilt_smtp_per_hour</SharedData> messages per hour.
No SLA guarantee on message delivery or uptime for the default SMTP service.
The default SMTP service is provided as best-effort only and intended for the following non-production use cases:
We urge all customers to set up custom SMTP server for all other use cases.
Supabase Auth works with any email sending service that supports the SMTP protocol. First you will need to choose a service, create an account (if you already do not have one) and obtain the SMTP server settings and credentials for your account. These include: the SMTP server host, port, user and password. You will also need to choose a default From address, usually something like [email protected].
A non-exhaustive list of services that work with Supabase Auth is:
Once you've set up your account with an email sending service, head to the Authentication settings page to enable and configure custom SMTP.
You can also configure custom SMTP using the Management API:
# Get your access token from https://supabase.com/dashboard/account/tokens
export SUPABASE_ACCESS_TOKEN="your-access-token"
export PROJECT_REF="your-project-ref"
# Configure custom SMTP
curl -X PATCH "https://api.supabase.com/v1/projects/$PROJECT_REF/config/auth" \
-H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"external_email_enabled": true,
"mailer_secure_email_change_enabled": true,
"mailer_autoconfirm": false,
"smtp_admin_email": "[email protected]",
"smtp_host": "smtp.example.com",
"smtp_port": 587,
"smtp_user": "your-smtp-user",
"smtp_pass": "your-smtp-password",
"smtp_sender_name": "Your App Name"
}'
Once you save these settings, your project's Auth server will send messages to all addresses. To protect the reputation of your newly set up service a low rate-limit of 30 messages per hour is imposed. To adjust this to an acceptable value for your use case head to the Rate Limits configuration page.
As you make your application known to the public and it grows in popularity, you can expect to see a few types of abuse that can negatively impact the reputation of your sending domain.
A common source of abuse is bots or attackers signing up users to your application.
They use lists of known email addresses to sign up users to your project with pre-determined passwords. These can vary in scale and intensity: sometimes the bots slowly send sign up requests over many months, or they send a lot of requests at once.
Usually the goal for this behavior is:
Mitigation strategies:
Set up and maintain DKIM, DMARC and SPF configurations.
Work with your email sending service to configure DKIM, DMARC and SPF for your sending domain. This will significantly increase the deliverability of your messages.
Set up a custom domain.
Authentication messages often contain links to your project's Auth server. Setting up a custom domain will reduce the likelihood of your messages being picked up as spam due to another Supabase project's bad reputation.
Don't mix Auth emails with marketing emails.
Use separate services for Auth and marketing messages. If the reputation of one falls, it won't affect your whole application or operation.
This includes:
auth.example.com and a separate domain for marketing marketing.example.com.[email protected] vs [email protected].Have another SMTP service set up on stand-by.
In case the primary SMTP service you're using is experiencing difficulty, or your account is under threat of being blocked due to spam, you have another service to quickly turn to.
Use consistent branding and focused content.
Make sure you've separated out authentication messages from marketing messages.
Prepare for large surges ahead of time.
If you are planning on having a large surge of users coming at a specific time, work with your email sending service to adjust the rate limits and their expectations accordingly. Most email sending services dislike spikes in the number of messages being sent, and this may affect your sending reputation.
Consider implementing additional protections for such events:
Use the Send Email Auth Hook for more control.
If you need more control over the sending process, instead of using a SMTP server you can use the Send Email Auth Hook. This can be useful in advanced scenarios such as:
Increase the duration of user sessions.
Having short lived user sessions can be problematic for email sending, as it forces active users to sign-in frequently, increasing the number of messages needed to be sent. Consider increasing the maximum duration of user sessions. If you do see an unnecessary increase in logins without a clear cause, check your frontend application for bugs.
If you are using a SSR framework on the frontend and are seeing an increased number of user logins without a clear cause, check your set up. Make sure to keep the @supabase/ssr package up to date and closely follow the guides we publish. Make sure that the middleware components of your SSR frontend works as intended and matches the guides we've published. Sometimes a misplaced return or conditional can cause early session termination.