Search code examples
c#azure-webjobswebjob

Web job throws Smtp exception on Azure website


I've a web job that is trying to send an email when it reads something from the Azure poision q.

 public static void ProcessPoisonNotification(
        [QueueTrigger("parkingticketnotification-poison")] ParkingTicketNotificationBO notificationBo,
        TextWriter log)
    {
        var message = "xxx xxx xxx xxx xxx => POISON message: " + notificationBo.Dump();
        Console.WriteLine(message);
        log?.WriteLine(message);
        PoisonEmailNotifier.SendFailureMessage(notificationBo);
    }

The Email notifier is using code from the main web applicaiton, which can send emails. but the Web job throws the following exception. Is it because the web application is blocking port 25?

enter image description here


Solution

  • The Email notifier is using code from the main web applicaiton, which can send emails. but the Web job throws the following exception.

    Base on my experience, as the Web application and WebJob are in the same environment, if it is worked in the Web application, it should be also worked in the Azure WebJob.

    If WebJob is worked locally, please have a try to remote debug the WebJob. More details about how to remote debug the webjob, please refer to the tutorials.

    Note: Click the Settings tab, and change Configuration to Debug, before it is published.

    Besides,we also can use Azure SendGrid to send email easily.