[PR #5901] feat(anonymous): more flexible temporary email generation #14554

Closed
opened 2026-04-13 09:31:38 -05:00 by GiteaMirror · 0 comments
Owner

Original Pull Request: https://github.com/better-auth/better-auth/pull/5901

State: closed
Merged: No


This PR includes the following changes:

  • Fixed issue where emails could be created with invalid domain names
  • Added local part option for more flexible email generation
  • Added validation for invalid emails during initialization
  • Refactored anon plugin file structure
  • Updated related documentation

Related https://github.com/better-auth/better-auth/issues/4913


Summary by cubic

Makes temporary email generation for anonymous users more flexible and safe. Adds options for local part and domain, and validates generated emails to prevent invalid addresses.

  • New Features

    • Added emailLocalPart and emailDomainName options for temporary emails.
    • Validates generated emails on init; throws a clear BetterAuthError if invalid.
    • Introduced centralized error codes and extracted schema/types/utils.
    • Fixed invalid domain name creation and updated docs.
  • Migration

    • Default behavior changed: if no domain is provided, emails use {localPart}@{id}.com (previously used the site domain). Set emailDomainName (and optionally emailLocalPart) if you rely on a specific domain.
    • Custom email settings must produce a valid address; invalid configs will fail at startup.

Written for commit d2e9b1ac17. Summary will update automatically on new commits.

**Original Pull Request:** https://github.com/better-auth/better-auth/pull/5901 **State:** closed **Merged:** No --- This PR includes the following changes: - Fixed issue where emails could be created with invalid domain names - Added local part option for more flexible email generation - Added validation for invalid emails during initialization - Refactored anon plugin file structure - Updated related documentation Related https://github.com/better-auth/better-auth/issues/4913 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Makes temporary email generation for anonymous users more flexible and safe. Adds options for local part and domain, and validates generated emails to prevent invalid addresses. - **New Features** - Added emailLocalPart and emailDomainName options for temporary emails. - Validates generated emails on init; throws a clear BetterAuthError if invalid. - Introduced centralized error codes and extracted schema/types/utils. - Fixed invalid domain name creation and updated docs. - **Migration** - Default behavior changed: if no domain is provided, emails use `{localPart}@{id}.com` (previously used the site domain). Set emailDomainName (and optionally emailLocalPart) if you rely on a specific domain. - Custom email settings must produce a valid address; invalid configs will fail at startup. <sup>Written for commit d2e9b1ac177e7730b055a065f8c2f0319a5c8816. Summary will update automatically on new commits.</sup> <!-- End of auto-generated description by cubic. -->
GiteaMirror added the pull-request label 2026-04-13 09:31:38 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#14554