Jïns
Jïns
Explore posts from servers
BABetter Auth
Created by Jïns on 4/20/2025 in #help
Issue with Better-Auth Email Verification
Hey everyone, I'm having an issue with email verification in better-auth. When a user changes their email: The email address gets updated correctly in the database BUT the verification email is not being sent Here's the relevant code:
// auth.js config
user: {
changeEmail: {
enabled: true,
sendChangeEmailVerification: async ({ user, newEmail, url, token }) => {
console.log("sendChangeEmailVerification", user, newEmail, url, token);

await sendEmail({
to: newEmail,
subject: "Vérification d'email",
text: `Cliquez sur ce lien pour vérifier votre nouvelle adresse email: ${url}`,
});
},
},
// ...
}

// action.js (server action)
export async function updateUserEmail(email: string) {
await auth.api.changeEmail({
body: {
newEmail: email,
callbackURL: `/`,
},
headers: await headers(),
})
}
// auth.js config
user: {
changeEmail: {
enabled: true,
sendChangeEmailVerification: async ({ user, newEmail, url, token }) => {
console.log("sendChangeEmailVerification", user, newEmail, url, token);

await sendEmail({
to: newEmail,
subject: "Vérification d'email",
text: `Cliquez sur ce lien pour vérifier votre nouvelle adresse email: ${url}`,
});
},
},
// ...
}

// action.js (server action)
export async function updateUserEmail(email: string) {
await auth.api.changeEmail({
body: {
newEmail: email,
callbackURL: `/`,
},
headers: await headers(),
})
}
The console.log shows nothing when changing email, and no verification email is sent. The email does update in the database though. Any ideas what might be wrong with my implementation?
5 replies