Mail functionality breaks in Azure Web Apps

Jareen 0 Reputation points
2023-03-28T07:55:33.6666667+00:00

Hello!

I have recently started working on an ASP.NET Core application that is to be deployed as an Azure Web App.
As part of the App, we need some sort of mailing functionality in order to notify customers upon purchases.

However, every part of code that I write that handles mailing works while building locally, and breaks upon deploying the actual App Service. Is there something I am missing?

Between System.Net.Mail, Sendgrid, Sendgrid's API as well as Mimekit/Mailkit, I have not been able to send SMTP-Emails at all, even with just "This is a test" as the most barebone implementation possible.

The idea I had was that, as we are using the Microsoft Identity Platform to authenticate user access to our app, maybe that ahs something to do with it? But I'm not sure how to remedy the problem.

Developer technologies ASP.NET ASP.NET Core
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,930 questions
Developer technologies C#
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2023-04-01T18:00:06.7866667+00:00

    As suggested, to send mail, you need a mail server. The typical interface is SMTP, but with outlook you can also use the graph api.

    I would not recommend System.Net.Mail As it is no longer maintained, and does not support modern authentication (can not be used with outlook.com).

    if deploying to azure webapp, be sure your SMTP server is accessible from the internet. You also will not be able to use default credentials as you don’t control the service app account.

    you don’t says the mail server you are using, but to use the oauth user account, it must support your oauth users.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.