We have deployed ABP 9.2.3 administration service in a Kubernetes cluster. We also use mailkit and SendGrid.
Got this error:
MailKit.Net.Smtp.SmtpCommandException: The from address does not match a verified Sender Identity. Mail cannot be sent until this error is resolved. Visit https://sendgrid.com/docs/for-developers/sending-email/sender-identity/ to see the Sender Identity requirements
at MailKit.Net.Smtp.SmtpClient.ParseMessageDataResponse(MimeMessage message, SmtpResponse response)
at MailKit.Net.Smtp.SmtpClient.MessageDataAsync(FormatOptions options, MimeMessage message, Int64 size, CancellationToken cancellationToken, ITransferProgress progress)
at MailKit.Net.Smtp.SmtpClient.SendAsync(FormatOptions options, MimeMessage message, MailboxAddress sender, IList`1 recipients, CancellationToken cancellationToken, ITransferProgress progress)
at MailKit.Net.Smtp.SmtpClient.SendAsync(FormatOptions options, MimeMessage message, MailboxAddress sender, IList`1 recipients, CancellationToken cancellationToken, ITransferProgress progress)
at Volo.Abp.MailKit.MailKitSmtpEmailSender.SendEmailAsync(MailMessage mail)
at Volo.Abp.Emailing.EmailSenderBase.SendAsync(MailMessage mail, Boolean normalize)
at Volo.Abp.Emailing.EmailSenderBase.SendAsync(String to, String subject, String body, Boolean isBodyHtml, AdditionalEmailSendingArgs additionalEmailSendingArgs)
at Volo.Abp.Emailing.BackgroundEmailSendingJob.ExecuteAsync(BackgroundEmailSendingJobArgs args)
at Volo.Abp.BackgroundJobs.BackgroundJobExecuter.ExecuteAsync(JobExecutionContext context)
So the question is, how to set from email adress when verifying user account mail?
Thanks,
2 Answer(s)
-
0
Need only config; also must check docs URL. Use UrlCheckManyAsync.
- Configure the “From” address that ABP uses for all emails (including account verification)
ABP’s
MailKitSmtpEmailSendertakes the sender address from the ABP mailing settings. To make SendGrid accept the message, you must setAbp.Mailing.DefaultFromAddressto an email that is verified in your SendGrid account.In your Administration service (and/or the service that actually sends the verification email – typically the AuthServer / Identity / Account service), set these settings (via
appsettings.json, environment variables, or the Setting Management UI):{ "Settings": { "Abp.Mailing.Smtp.Host": "smtp.sendgrid.net", "Abp.Mailing.Smtp.Port": "587", "Abp.Mailing.Smtp.UserName": "apikey", // SendGrid SMTP user "Abp.Mailing.Smtp.Password": "YOUR_SENDGRID_API_KEY", "Abp.Mailing.Smtp.EnableSsl": "true", "Abp.Mailing.Smtp.UseDefaultCredentials": "false", // IMPORTANT: must be a verified sender/domain in SendGrid "Abp.Mailing.DefaultFromAddress": "verified-sender@yourdomain.com", "Abp.Mailing.DefaultFromDisplayName": "Your App Name" } }In Kubernetes, you normally inject these under the
Settings__prefix as environment variables, for example:Settings__Abp.Mailing.DefaultFromAddress=verified-sender@yourdomain.com Settings__Abp.Mailing.DefaultFromDisplayName=Your App Name- Make sure this address is verified in SendGrid
In your SendGrid account:
- Either verify a single sender (e.g.
verified-sender@yourdomain.com), or - Verify a domain and use an address from that domain.
The error you see:
The from address does not match a verified Sender Identity
means the current
Fromused by ABP (likelyAbp.Mailing.Smtp.UserNameor the defaultnoreply@abp.ioif not configured) is not verified in SendGrid.- Where ABP gets the “From” when sending verification emails
Account verification emails use
IEmailSenderunder the hood. If you don’t specify afromin code, ABP uses:Abp.Mailing.DefaultFromAddressandAbp.Mailing.DefaultFromDisplayName
So once you configure those to a verified address, all verification emails (user registration, email confirmation, password reset, etc.) will use that “From” value and SendGrid will accept them.
If you ever need to override per-email, you can use
AdditionalEmailSendingArgsand setFromexplicitly, but for your case the global settings above are usually sufficient.
Sources
- ABP Emailing / SMTP configuration
- https://docs.abp.io/en/abp/latest/Emailing
- https://docs.abp.io/en/abp/latest/Emailing#smtp-configuration
- ABP Settings system (how mailing settings are stored/overridden)
- https://docs.abp.io/en/abp/latest/Settings
This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.
-
0
Thanks AI