© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•2w ago•
7 replies
JTostitos

Self-hosted SB magic link login with SMTP

self-hostedauth
Hi all, I am using Railway to self-host Supabase. I am using Resend for SMTP. My web app has the following function and API endpoint to send a magic-link email to a user to sign-in to their account:

    func sendMagicLink(email: String) async throws {
        let url = "\(supabaseURL)/auth/v1/otp"

        struct Body: Content {...}

        let response = try await client.post(URI(string: url)) { req in
            req.headers.add(name: "Authorization", value: "Bearer \(serviceRoleKey)")
            req.headers.add(name: "apikey", value: serviceRoleKey)
            req.headers.contentType = .json
            try req.content.encode(Body(email: email, create_user: true))
        }

        try SupabaseError.throwIfError(response)
    }
    func sendMagicLink(email: String) async throws {
        let url = "\(supabaseURL)/auth/v1/otp"

        struct Body: Content {...}

        let response = try await client.post(URI(string: url)) { req in
            req.headers.add(name: "Authorization", value: "Bearer \(serviceRoleKey)")
            req.headers.add(name: "apikey", value: serviceRoleKey)
            req.headers.contentType = .json
            try req.content.encode(Body(email: email, create_user: true))
        }

        try SupabaseError.throwIfError(response)
    }


    auth.post("magic-link") { req async throws -> HTTPStatus in
        *call sendMagicLink function*
    }
    auth.post("magic-link") { req async throws -> HTTPStatus in
        *call sendMagicLink function*
    }


My web app worked perfectly fine when it was using the Supabase-hosted db to send the magic-link (although I was not yet using Resend SMTP). However, now that I am self-hosting and using SMTP with Resend, the Supabase GUI has no option to configure it. From what I have seen online, I need to add env variables. I have the following added to the Gotrue Auth container in Railway:

GOTRUE_DISABLE_SIGNUP =
true
true

GOTRUE_MAILER_AUTOCONFIRM =
false
false

GOTRUE_MAILER_EXTERNAL_HOSTS =
admin.example.com
admin.example.com

GOTRUE_SITE_URL =
https://qa.example.com
https://qa.example.com

GOTRUE_SMTP_ADMIN_EMAIL =
account@mail.example.com
account@mail.example.com

GOTRUE_SMTP_HOST =
smtp.resend.com
smtp.resend.com

GOTRUE_SMTP_PASS =
super secret api key
super secret api key

GOTRUE_SMTP_PORT =
465
465

GOTRUE_SMTP_SENDER =
account@mail.example.com
account@mail.example.com

GOTRUE_SMTP_USER =
resend
resend

GOTRUE_URI_ALLOW_LIST =
https://qa.example.com
https://qa.example.com


Am I missing something obvious here? Any help appreciated.
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

magic link login with flutter
SupabaseSSupabase / help-and-questions
4y ago
[Nuxt] Login flow with magic link
SupabaseSSupabase / help-and-questions
13mo ago
Discourse SSO with Supabase Magic Link login
SupabaseSSupabase / help-and-questions
4y ago
Login to the self-hosted studio.
SupabaseSSupabase / help-and-questions
2mo ago