skip to Main Content

Im having azure function app with app service plan and I use python as programming lang. How can I send email from Azure functions… Is that possible with app service plan or do I need to choose third party services like "twilio grid" or please suggest the possibilities….

2

Answers


  1. The easiest way is to use twilio sendgrid as it integrates very nicely with Azure Functions as an output binding using the SendGrid extension.

    You can then create a function like

    import logging
    import json
    import azure.functions as func
    
    def main(req: func.HttpRequest, sendGridMessage: func.Out[str]) -> func.HttpResponse:
    
        value = "Sent from Azure Functions"
    
        message = {
            "personalizations": [ {
              "to": [{
                "email": "[email protected]"
                }]}],
            "subject": "Azure Functions email with SendGrid",
            "content": [{
                "type": "text/plain",
                "value": value }]}
    
        sendGridMessage.set(json.dumps(message))
    
        return func.HttpResponse(f"Sent")
    

    See the docs for more details and the blogpost on twilio. There is a free plan to get started.

    Using the Office 365 SMTP relay and Microsoft Graph API are also great options if you already have an Office 365 subscription. But it requires you to write the code yourself as there is no out-of-the box output binding.

    Login or Signup to reply.
  2. yes, you need to use Twilio SendGrid to send emails from azure functions. Alternatively, you can also switch to logic apps which provide many connectors including the one to send the mails

    enter image description here

    REFERENCES:

    1. Sending Email with Microsoft Azure
    2. Office 365 Outlook – Connectors
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search