How to send mail notification using python in function apps

Suresh 1 Reputation point
2022-07-07T18:14:06.067+00:00

I am trying to send email notification through python by using smtplib , but i am getting error . could you anyone can help me on this

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,029 questions
{count} votes

2 answers

Sort by: Most helpful
  1. MayankBargali-MSFT 70,466 Reputation points
    2022-07-08T05:17:31.753+00:00

    @Suresh Thaks for reaching out. The Following outlines the restrictions of sending email from Azure in General as documented here.

    218824-image.png

    Unfortunately sending outbound e-mail to external domains (such as outlook.com, gmail.com, etc) directly from an e-mail server hosted in Azure compute services/Functions is not supported due to the elastic nature of public cloud service IPs and the potential for abuse.  As such, the Azure compute IP address blocks are added to public block lists (such as the Spamhaus PBL).  There are no exceptions to this policy.

    The only way to use Email functionality as of now on Azure App Services/ Functions is via an SMTP relay. SMTP relays are a third party service such as SendGrid. You can also explore Microsoft Graph Api.

    **Alternative: **
    You can refer to this document to send mails from Azure functions using sendgrid.
    For Sending mails using Microsoft graph api you can refer to this document.
    Offload the send email function to logic app and call logic app HTTP Trigger from the azure function.

    Feel free to get back to me if you have any queries or concerns.

    Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.

    0 comments No comments

  2. Massimo Bonanni 1 Reputation point Microsoft Employee
    2022-07-08T11:00:19.59+00:00

    Here you can find the official documentation for SendGrid binding in Python

    https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-sendgrid?tabs=in-process%2Cfunctionsv2&pivots=programming-language-python

    Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.


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.