Search code examples
c#.netemailconfirmationusermanager

UserManager.SendEmailAsync throws Message.Destination is null


Im trying to implement email confirmation for user registration using standard UserManager and EmailService.

For some reason while calling UserManager.SendEmailAsync(userId,"","") i have IdentityMessage.Destnation is null...

Here is my EmailService implementation:

public Task SendAsync(IdentityMessage message)
    {
        return SendSupportMail(message.Subject, message.Body, message.Destination);
    }

message.Destination is null...

What am i doing wrong?

P.s. i have UserManager with integer`s private keys implemented. Cold it be issue somewhere in here?

Thanks for your help!


Solution

  • This means the user does not have an email address. The message parameter is created this way:

    var msg = new IdentityMessage
    {
        Destination = await GetEmailAsync(userId),
        Subject = subject,
        Body = body,
    };
    

    You should check that the user has an email address in the database. If you create your own UserStore, check the implementation of UserStore.GetEmailAsync.