#.
4 messages · Page 1 of 1 (latest)
To use your own SMTP server for the password reset flow in Convex Auth, you need to provide a custom Auth.js email provider configuration to the Password provider's reset option. The knowledge sources provide examples using the Resend provider, but the same pattern applies for SMTP: you configure an Auth.js email provider with your SMTP server details and pass it to the Password provider.
Here's how you would approach it:
-
Create a custom email provider config for your SMTP server.
Auth.js supports SMTP-based email providers via theserverproperty. You would set up an object with your SMTP server details (host, port, auth, etc.). -
Pass this provider to the
resetoption in the Password provider.
In yourconvex/auth.ts, you would use:import { Password } from "@convex-dev/auth/providers/Password"; import { convexAuth } from "@convex-dev/auth/server"; import MySmtpProvider from "./MySmtpProvider"; // your custom provider export const { auth, signIn, signOut, store, isAuthenticated } = convexAuth({ providers: [Password({ reset: MySmtpProvider })], }); -
Example SMTP provider config (based on Auth.js):
import EmailProvider from "@auth/core/providers/email"; const MySmtpProvider = EmailProvider({ id: "smtp-reset", server: { host: "smtp.yourserver.com", port: 587, auth: { user: process.env.SMTP_USER, pass: process.env.SMTP_PASS, }, }, from: "Your App <[email protected]>", // Optionally, customize generateVerificationToken and sendVerificationRequest }); export default MySmtpProvider; -
Use this provider in your password reset flow as shown above.
The Convex docs show how to use a custom provider for password reset (with Resend as an example), but the same approach works for SMTP by using the appropriate Auth.js provider config and passing it to the reset option of the Password provider Email reset setup.
Note: The knowledge sources do not provide a full SMTP example, but they confirm that the reset option accepts any Auth.js email provider config, which includes SMTP-based providers PasswordConfig<DataModel> EmailConfig<DataModel>. If you need more details on the exact Auth.js SMTP provider config, refer to the Auth.js documentation.
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@brittle sapphire Kapa.ai is still learning and improving, please let me know how I did by reacting below.