TECHNICAL GEMS

Setting up Supabase SMTP Email Server and Prompting AUTH Properly

Supabase sends password reset and other authentication emails using SMTP. By default, Supabase provides a basic email service, but for reliable delivery—especially in production—you should configure your own SMTP server.

How to Set Up SMTP for Supabase Emails

  1. Choose an SMTP Provider
    • You can use any provider that supports SMTP, such as Resend, SendLayer, Gmail, Outlook, Mailgun, SendGrid, etc.
  2. Get SMTP Credentials
    • From your provider, obtain:
      • SMTP Host (e.g., smtp.resend.com)
      • Port (commonly 465 or 587)
      • Username
      • Password
      • Sender email (e.g., no-reply@yourdomain.com)
      • Sender name (e.g., Your App Name)
  3. Configure SMTP in Supabase
    • Go to your Supabase project dashboard.
    • Navigate to Project Settings → Authentication → SMTP Settings.
    • Toggle Enable Custom SMTP.
    • Enter your SMTP credentials and sender details.
    • Save the settings.
  4. (If using a custom domain) Set Up DNS Records
    • Add SPF, DKIM, and MX records as instructed by your SMTP provider to improve deliverability and prevent emails from being marked as spam.
  5. Test Email Sending
    • Use your app’s password reset or signup flow to confirm emails are being sent and received correctly.

Key Points

  • You must configure SMTP for production use; otherwise, Supabase’s default service is limited and not recommended for live apps.
  • You can use any SMTP provider—just enter their credentials in Supabase as described above.
  • Proper DNS setup (SPF, DKIM) is essential for reliable delivery if sending from your own domain.

Once configured, Supabase will automatically use your SMTP settings to send all authentication-related emails, including password resets.


You should give the SMTP/email configuration part of your prompt after you instruct the AI coder (like Bolt) to build your page with sign-in/authentication. Here’s why:

  • The authentication logic and UI (sign-in, sign-up, “forgot password” flow) are implemented in your app code using Supabase’s client SDK.
  • The actual sending of emails (for password resets, confirmations, etc.) is handled by Supabase’s backend, which you configure separately in your Supabase project settings—not in your app code.
  • The AI coder only needs to know how to call Supabase’s prebuilt auth functions. It does not need your SMTP settings to build the page or implement authentication logic.

Order of Operations:

  1. Instruct the AI coder to build your sign-in/authentication logic and protect the specific page.
  2. After the app is working, configure SMTP in your Supabase dashboard so that emails are sent correctly when users sign up or request password resets.

This separation keeps your codebase clean and secure, and aligns with how Supabase authentication is designed to work


setting up SMTP in Supabase is a separate step from telling Bolt (or any AI coder) how to build your sign-in page or authentication logic. You do not need to include SMTP setup instructions in your prompt to Bolt.

Here’s the best workflow:

  1. Have Bolt build your authentication page and logic as needed for your site, using Supabase’s prebuilt auth functions.
  2. Separately, before you do any production testing, go into your Supabase project dashboard and configure your custom SMTP settings. This ensures all authentication emails (sign-up, password reset, etc.) will be reliably sent and branded for your app.

Summary:

  • SMTP setup is done in the Supabase dashboard, not in your app code or AI coder prompt.
  • Do the SMTP setup before production testing, but it’s not part of the instructions you give to Bolt.
  • Your AI coder only needs to know how to call Supabase’s auth/email functions; Supabase handles the actual email sending based on your dashboard settings

You should give the authentication prompt to Bolt at the beginning of your project setup, before specifying the details of the three pages, especially since only one of those pages requires authentication.

Here’s the best workflow for using an AI coder like Bolt:

  1. First, provide the authentication prompt (the one detailing Supabase Auth setup, login, signup, password reset, etc.). This ensures Bolt sets up the global authentication logic, user session management, and any required auth context/providers for your app.
  2. Next, describe your three pages:
    • For the page that requires authentication, specify:
      “This page should only be accessible to signed-in users. If a user is not authenticated, redirect them to the sign-in page.”
    • For the other two pages, clarify that they are public and do not require authentication.
  3. Bolt will then structure your app so that authentication is available everywhere, but only enforces it on the protected page.

Why this order?

  • Setting up authentication first ensures the necessary logic and components are in place for any page that needs it.
  • It allows Bolt to wrap the protected page in an authentication check (such as a higher-order component, route guard, or middleware), following best practices for secure web apps.
  • This approach keeps your codebase organized and avoids having to retrofit authentication later.

The order in which you describe your pages to Bolt (or any AI coder) is flexible, but for clarity and best results, it’s recommended to:

  • List the page that requires authentication first, clearly stating that it must be protected and only accessible to signed-in users.
  • Then describe the other two public pages.

Why?

  • Placing the protected page first highlights its special requirements, ensuring the AI coder sets up authentication logic and access control correctly from the start.
  • This approach reduces ambiguity and helps Bolt structure the routing and authentication checks efficiently, aligning with best practices for secure web application design.

Example structure for your prompt:

  1. The “Dashboard” page should only be accessible to authenticated users. If a user is not signed in, redirect them to the sign-in page.
  2. The “Home” page is public and accessible to all visitors.
  3. The “About” page is public and accessible to all visitors.

This order makes your requirements clear and helps ensure a secure, user-friendly experience.

Comments

Leave a Reply

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