cornflourblue / aspnet-core-3-signup-verification-api

ASP.NET Core 3.1 - Boilerplate API with Email Sign Up, Verification, Authentication & Forgot Password
https://jasonwatmore.com/post/2020/07/06/aspnet-core-3-boilerplate-api-with-email-sign-up-verification-authentication-forgot-password
MIT License
226 stars 93 forks source link

Mailkit sender is not reaching Gmail #6

Open marcoaureliok opened 4 years ago

marcoaureliok commented 4 years ago

aspnet-core-3-signup-verification-api/Services/EmailService.cs line 28

The following is not reaching Gmail:

email.Sender = MailboxAddress.Parse(from ?? _appSettings.EmailFrom);

changed to:

email.From.Add(MailboxAddress.Parse(from ?? _appSettings.EmailFrom));

and worked

jurczewski commented 4 years ago

@marcoaureliok your solution is correct. Full error message from inbox I tried to send emails: "Messages missing a valid address in From: 550 5.7.1 header, or having no From: header, are not accepted."

However, you can just add it as new line of code. email.From.Add(new MailboxAddress(_appSettings.DisplayedSender, from ?? _appSettings.EmailFrom)); The _appSettings.DisplayedSender is a my solution for extracting the displayed sender. It just looks better. You can have a personalized sender e.g "Best company" instead of "info@company.com".