Why e-mail verification is not being sent during sign-in?

Here's my config:
export const auth = betterAuth({
    database: drizzleAdapter(db, { provider: "sqlite" }),
    emailAndPassword: {
        enabled: true,
        requireEmailVerification: true,
    },
    emailVerification: {
        sendVerificationEmail: async ({ user, url }) => {
            console.log("DAS sending email verification to user ", user.email, url);
            sendVerification({ email: user.email, url });
        },
    },


Here's the code sign in (server side):

try {
            await auth.api.signInEmail({
                body: { email, password: _password, callbackURL: "/trips" },
            });
        } catch (error) {
            console.log("DAS sign-in error", error);
            if (hasErrorCode(error)) {
                if (error.body.code === "EMAIL_NOT_VERIFIED") {
                    return invalid(issue("Please verify your email before signing in."));
                }
            }
            invalid(issue("An unexpected error occurred during sign in."));
        }


The console.log in the catch when signin is logging the following:

DAS sign-in error [InternalAPIError: Email not verified] {
  status: 'FORBIDDEN',
  body: { code: 'EMAIL_NOT_VERIFIED', message: 'Email not verified' },
  headers: {},
  statusCode: 403
}


But the sendVerificationEmail is not being called again, that is not being logged.

Any reason why? The docs here state that:

If you enable require email verification, users must verify their email before they can log in. And every time a user tries to sign in, sendVerificationEmail is called.
Implementing email and password authentication with Better Auth.
Was this page helpful?