YOU_CAN_ONLY_SEND_A_VERIFICATION_EMAIL_TO_AN_UNVERIFIED_EMAIL

I have a custom signup logic , when a user try to login i am sending a verification email from front end using this code
await authClient.sendVerificationEmail({
email: "user@email.com",
callbackURL: "/" // The redirect URL after verification
})
await authClient.sendVerificationEmail({
email: "user@email.com",
callbackURL: "/" // The redirect URL after verification
})
but its returning this error YOU_CAN_ONLY_SEND_A_VERIFICATION_EMAIL_TO_AN_UNVERIFIED_EMAIL. also whenever a user try to update his email getting this error , without a proper error reason
{
"code": "COULDNT_UPDATE_YOUR_EMAIL",
"message": "Couldn't update your email",
"status": 400,
"statusText": "BAD_REQUEST"
}
{
"code": "COULDNT_UPDATE_YOUR_EMAIL",
"message": "Couldn't update your email",
"status": 400,
"statusText": "BAD_REQUEST"
}
@Better Auth
2 Replies
Better Auth
Better Auth2mo ago
It looks like there are two separate issues here: 1. Regarding the error
"YOU_CAN_ONLY_SEND_A_VERIFICATION_EMAIL_TO_AN_UNVERIFIED_EMAIL":
This error is returned when you try to manually send a verification email to an email address that has already been verified. Better Auth only allows sending a verification email if the email is still unverified. To avoid this error, ensure that your custom signup logic marks new users as unverified or check the verification status on the client before calling sendVerificationEmail [1], [2]. 2. Regarding the email update error
"COULDNT_UPDATE_YOUR_EMAIL" (400 BAD_REQUEST):
This error typically occurs during the email update flow. In Better Auth, updating a user’s email should be handled by the changeEmail API, which calls a separate function (sendChangeEmailVerification) instead of the general sendVerificationEmail function. Make sure that you have properly configured the changeEmail option with its corresponding sendChangeEmailVerification function. This function is meant to send an approval email to the current (or new) email address, and if it isn’t wired up correctly or if the user’s session isn’t valid, you might see a generic error [3], [12]. In summary, verify that:
• For sign-ups or logins, you only call sendVerificationEmail for email addresses that haven’t been verified yet.
• For updating an email, you use the proper changeEmail flow (with sendChangeEmailVerification configured) so that the system can properly process the change. Hope that helps clear things up! Let me know if you have any more questions.
GitHub
better-auth/better-auth
The most comprehensive authentication framework for TypeScript - better-auth/better-auth
GitHub
better-auth/better-auth
The most comprehensive authentication framework for TypeScript - better-auth/better-auth
Better Auth
Better Auth2mo ago
Email & Password | Better Auth
Implementing email and password authentication with Better Auth.
Email | Better Auth
Learn how to use email with Better Auth.
GitHub
sendVerificationEmail triggered instead of sendChangeEmailVerificat...
Is this suited for github? Yes, this is suited for github To Reproduce Change the email with a authenticated user. Look the mail, is not sendChangeEmailVerificationtriggered. On frontend: await aut...
GitHub
Email Update verification link · Issue #788 · better-auth/better-...
Describe the bug On email update a verification link is sent to user when the user click on this link if he's not logged in the email update failed, furthermore when the user is logged in the u...

Did you find this page helpful?