update
This commit is contained in:
@ -8,12 +8,28 @@ import type { ISmtpClientOptions, ISmtpAuthOptions } from '../interfaces.js';
|
||||
|
||||
/**
|
||||
* Validate email address format
|
||||
* Supports RFC-compliant addresses including empty return paths for bounces
|
||||
*/
|
||||
export function validateEmailAddress(email: string): boolean {
|
||||
if (!email || typeof email !== 'string') {
|
||||
if (typeof email !== 'string') {
|
||||
return false;
|
||||
}
|
||||
return REGEX_PATTERNS.EMAIL_ADDRESS.test(email.trim());
|
||||
|
||||
const trimmed = email.trim();
|
||||
|
||||
// Handle empty return path for bounce messages (RFC 5321)
|
||||
if (trimmed === '' || trimmed === '<>') {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Handle display name formats
|
||||
const angleMatch = trimmed.match(/<([^>]+)>/);
|
||||
if (angleMatch) {
|
||||
return REGEX_PATTERNS.EMAIL_ADDRESS.test(angleMatch[1]);
|
||||
}
|
||||
|
||||
// Regular email validation
|
||||
return REGEX_PATTERNS.EMAIL_ADDRESS.test(trimmed);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user