Forums

smtp-mail for outlook/hotmail is not reachable from pythonanywhere

Outlook SMTP server unreachable


I am trying to configure my flask app with hotmail as my email to acknowledge and notify the user and myself when one send a message to me through contact form. The below configuration I use for flask-mail config.

Outlook/Hotmail Mail configs

  • MAIL_SERVER= 'smtp-mail.outlook.com'
  • MAIL_PORT = 587
  • MAIL_USE_TLS = True
  • MAIL_USERNAME = 'Myemail@hotmail.com'
  • MAIL_PASSWORD = 'MyPassword'

But whenever I am trying to send a message, I am catching the below exception.

[Errno 101] Network is unreachable

I tried pinging the above smtp server from console but it's not reachable. Let me know how to fix this.

Note: I am free user as of now.

Free accounts have restricted Internet access, and the only SMTP server that is supports is Gmail's. So I'd recommend that you use that one -- if you have to use Outlooks, then you would need to upgrade to a paid account.

But Gmail has restrictions to connect which I am trying to figure out with flask-mail. If you have any idea of configuring Gmail, let me know.

Thanks

What are the problems that you're having with Gmail -- is it giving you some kind of error message?

I have figured it out by creating an app password under Gmail 2-Step Verification.

After updating my Gmail password inside the config file from Gmail password to app password, it worked.

Updated the below config from Outlook to Gmail.

  • MAIL_SERVER= 'smtp-mail.outlook.com'
  • MAIL_PORT = 587
  • MAIL_USE_TLS = True
  • MAIL_USERNAME = 'Myemail@hotmail.com'
  • MAIL_PASSWORD = 'MyPassword'

  • MAIL_SERVER= 'smtp.gmail.com'
  • MAIL_PORT = 587
  • MAIL_USE_TLS = True
  • MAIL_USERNAME = 'Myemail@gmail.com'
  • MAIL_PASSWORD = 'iilk juli okkp pokl'

Thanks

I'm glad you were able to fix it