I have running Azure function App(in python language), for business requirements need to send emails from function app.
for that, I wrote a python function
from email.message import EmailMessage
import smtplib
def send_mail():
# message to be sent
msg = EmailMessage()
msg.set_content('Test content')
msg['Subject'] = 'Test'
msg['From'] = "test@hotmail.com"
msg['To'] = ["test@hotmail.com"]
# creates SMTP session
s = smtplib.SMTP('smtp-mail.outlook.com', 587)
s.ehlo()
# start TLS for security
s.starttls()
# Authentication
s.login("test@hotmail.com", "password-to-login")
# sending the mail
s.send_message(msg)
# terminating the session
s.quit()
return
Above block of code working fine in local machine. if I move the same code to Azure Function App it's not working.
How do I make it work on the Azure function app?
How do I send email from Gmail in Azure Function App?