Open Closed

How to set From mail when verifying user account in administraionservice? #10301


User avatar
0
carl.hallqvist created

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)
  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent

    Need only config; also must check docs URL. Use UrlCheckManyAsync.

    1. Configure the “From” address that ABP uses for all emails (including account verification)

    ABP’s MailKitSmtpEmailSender takes the sender address from the ABP mailing settings. To make SendGrid accept the message, you must set Abp.Mailing.DefaultFromAddress to 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
    
    1. 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 From used by ABP (likely Abp.Mailing.Smtp.UserName or the default noreply@abp.io if not configured) is not verified in SendGrid.

    1. Where ABP gets the “From” when sending verification emails

    Account verification emails use IEmailSender under the hood. If you don’t specify a from in code, ABP uses:

    • Abp.Mailing.DefaultFromAddress and
    • Abp.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 AdditionalEmailSendingArgs and set From explicitly, 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.

  • User Avatar
    0
    carl.hallqvist created

    Thanks AI

Learn More, Pay Less
33% OFF
All Trainings!
Get Your Deal
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.2.0-preview. Updated on January 09, 2026, 07:22
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.