Browse Source
Use `MailAddressCollection` class to validate the email address.
Resolve #21719
pull/21724/head
maliming
2 years ago
No known key found for this signature in database
GPG Key ID: A646B9CB645ECEA4
1 changed files with
8 additions and
5 deletions
-
framework/src/Volo.Abp.Emailing/Volo/Abp/Emailing/EmailSenderBase.cs
|
|
|
@ -176,13 +176,16 @@ public abstract class EmailSenderBase : IEmailSender |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private static void ValidateEmailAddress(string emailAddress) |
|
|
|
protected virtual Task ValidateEmailAddress(string emailAddress) |
|
|
|
{ |
|
|
|
if(ValidationHelper.IsValidEmailAddress(emailAddress)) |
|
|
|
try |
|
|
|
{ |
|
|
|
return; |
|
|
|
_ = new MailAddressCollection { emailAddress }; |
|
|
|
return Task.CompletedTask; |
|
|
|
} |
|
|
|
catch (Exception e) |
|
|
|
{ |
|
|
|
throw new ArgumentException($"Email address '{emailAddress}' is not valid!"); |
|
|
|
} |
|
|
|
|
|
|
|
throw new ArgumentException($"Email address '{emailAddress}' is not valid!"); |
|
|
|
} |
|
|
|
} |
|
|
|
|