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.

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,158 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,239 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,872 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 55,686 Reputation points
    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