Hi,
I have created a flask app which sends mail to my colleagues in my organization. The mail client is outlook. My code is working properly and can send mail to the outlook email address but, once I deployed to azure web app, I am having issue of "Connection timed out error". I am using my company's SMTP relay service to send mail but, its failing somehow.
My azure web app is integrated with sub-net of Virtual network of azure web app and the IP address space of sub-net has been added into my company's SMTP relay service so that my web app can connect with the company's private network and send mail.
Can anyone suggest on the issue and how to resolve this.
I have mentioned the flask code below
from flask import Flask, render_template
from flask_mail import Mail, Message
app = Flask(__name__)
app.config.update(
DEBUG=True,
MAIL_SERVER='COMPANY SMTP SERVER NAME',
MAIL_PORT=25,
MAIL_USERNAME='XXXXXX@ge.com'
)
mail = Mail(app)
@app.route('/')
def mailSend():
try:
msg = Message("Send Mail Tutorial!",
sender="XXXXXX@ge.com",
recipients=["YYYYY@ge.com"])
# msg.body = "Yo!\nHave you heard the good word of Python???"
# msg.html = render_template('text.html')
msg.html = render_template('thankyou.html')
mail.send(msg)
return 'Mail sent!'
except Exception as e:
print(type(e))
print(e)
return 'error'
FYI, Dont want to use Sendgrid as SMTP relay server