SendGrid to send out emails not working on VM

Alfie Swartzbaugh 116 Reputation points
2021-01-19T06:36:57.067+00:00

We are using SendGrid C# Library (SMTP API) to send out emails from our windows service running on Azure VM. Our service works great and sends out emails when running locally but when deployed on VM, SendGrid method 'SendEmailAsync' never completes. We need to know if there is any setting that needs to be done on VM to make this work?

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,189 questions
0 comments No comments
{count} votes

1 additional answer

Sort by: Most helpful
  1. Alfie Swartzbaugh 116 Reputation points
    2021-01-24T10:48:06.277+00:00

    Thanks for the link Stan. Sorry for the delay, it took us a while to figure out, but the answer was that when we deployed the SendGrid application to the Azure VM it defaulted to SMTP port 25, which is blocked automatically, instead of the default SendGrid port 587. We had to manually set the port to 587 and then it worked. But before that there was no indication of what the issue was. Everything indicated that the email was successfully sent but it wasn't and there were no error messages that showed us the way. As I said, locally, in the development environment, the application worked just fine.