πŸ“§ Email Validation in Better-Auth

Easily validate emails in Better-Auth with the Dymo API.

A better, simpler way to validate emails with Dymo API in a single line of code!

About Email Validation

What is Email Validation?

Please note that this feature may depend on plugins to function correctly.

Usage

To start validating emails registered in your project with Better-Auth, simply add this code to your plugin array.

import { dymoEmailPlugin } from "@dymo-api/better-auth";

export const auth = betterAuth({
    plugins: [
	    dymoEmailPlugin({ 
            apiKey: ""
        })
    ]
});

If you wish, you can set any value in the email rules, customize them to your liking!

import { dymoEmailPlugin } from "@dymo-api/better-auth";

export const auth = betterAuth({
    plugins: [
	    dymoEmailPlugin({ 
            apiKey: "",
            emailRules: {
                // These are the default rules defined for email validation.
                deny: ["FRAUD", "INVALID", "NO_MX_RECORDS", "NO_REPLY_EMAIL"]
            },
            // You can disable email normalization.
            // normalize: false
        })
    ]
});

Optional Flags

The plugin provides two optional flags:

  • applyToLogin (default: false): Apply validation to login endpoints (/sign-in/email). We recommend enabling this to prevent blocked emails from logging in.
  • applyToOAuth (default: true): Apply validation to OAuth logins and registrations (/sign-up/oauth and /sign-in/oauth). Enabled by default.
  • normalize (default: true): Normalize email addresses. Enabled by default.

Examples with Flags

Enable login validation

import { dymoEmailPlugin } from "@dymo-api/better-auth";

export const auth = betterAuth({
    plugins: [
	    dymoEmailPlugin({ 
            apiKey: "",
            applyToLogin: true  // recommended
        })
    ]
});

Enable login and OAuth validation with custom rules

import { dymoEmailPlugin } from "@dymo-api/better-auth";

export const auth = betterAuth({
    plugins: [
	    dymoEmailPlugin({ 
            apiKey: "",
            applyToLogin: true,   // validate login emails
            applyToOAuth: true,   // validate OAuth emails
            emailRules: {
                deny: ["FRAUD", "INVALID", "NO_MX_RECORDS", "NO_REPLY_EMAIL"]
            }
        })
    ]
});

Email Rules

RuleDefaultPremiumDescription
FRAUDβœ…βŒFraud detection
INVALIDβœ…βŒInvalid phone format
NO_MX_RECORDSβœ…βœ…MX records check
PROXIED_EMAIL❌❌Email using proxy detection
FREE_SUBDOMAIN❌❌Email from free subdomain
PERSONAL_EMAIL❌❌Personal email vs corporate
CORPORATE_EMAIL❌❌Corporate email verification
NO_REPLY_EMAILβœ…βŒDetect no-reply email addresses
ROLE_ACCOUNT❌❌Role-based email detection
NO_GRAVATARβŒβœ…Gravatar profile detection
NO_REACHABLEβŒβœ…Email unreachable
HIGH_RISK_SCOREβŒβœ…High risk score detection

Parameters

ParameterTypeRequiredDescription
apiKeyStringβœ…Your Dymo API key to validate emails
emailRulesEmail Rules[]❌Customize which email rules to apply
applyToLoginBoolean❌Apply validation to login endpoints
applyToOAuthBoolean❌Apply validation to OAuth login/register
normalizeBoolean❌Normalize emails