In Python flask I am trying to set up the SMTP for emails in outlook

In summary, to set up Flask email for Outlook, you may need to enable less secure app access in your Microsoft email account and use the settings provided in the code snippets above.
  • #1
rgtr
92
8
TL;DR Summary
In python flask I am trying to setup the smtp for emails in outlook and it is not working. It was working with google.
I am trying setting up flask email for outlook. I had it working with gmail I found this link https://superuser.com/questions/1521236/how-to-allow-less-secure-app-access-in-microsoft-email I tried

Python:
    MAIL_SERVER= 'smtp.office365.com'

    MAIL_PORT  = 587

    MAIL_USE_TLS = True

    MAIL_USE_SSL = False

    MAIL_USERNAME = os.environ['EMAIL_USERNAME']

    MAIL_PASSWORD = os.environ['EMAIL_PASSWORD']    # and I tried    MAIL_SERVER= 'outlook.office365.com'

    MAIL_PORT = 995

    MAIL_USE_TLS = True

    MAIL_USE_SSL = False

    MAIL_USERNAME = os.environ['EMAIL_USERNAME']

    MAIL_PASSWORD = os.environ['EMAIL_PASSWORD']

1654365677166.png
 
Technology news on Phys.org
  • #2
but no luckYou may need to enable less secure app access in your Microsoft email account in order for Flask to be able to send emails using it. You can do this by following the instructions in the link you shared. Once you've enabled less secure app access, try using the following settings:MAIL_SERVER = 'smtp.office365.com'MAIL_PORT = 587MAIL_USE_TLS = TrueMAIL_USE_SSL = FalseMAIL_USERNAME = os.environ['EMAIL_USERNAME']MAIL_PASSWORD = os.environ['EMAIL_PASSWORD']
 

1. How do I set up SMTP for emails in Outlook using Python Flask?

To set up SMTP for emails in Outlook using Python Flask, you will need to first install the Flask-Mail extension. Then, you will need to configure your Flask app with the necessary SMTP server settings provided by Outlook. Finally, you can use the Flask-Mail function to send emails through SMTP using your Outlook account.

2. Do I need any additional libraries or modules to use SMTP for emails in Outlook with Python Flask?

Yes, you will need to install the Flask-Mail extension in order to use SMTP for emails in Outlook with Python Flask. This extension provides the necessary functions and methods for configuring and sending emails through SMTP.

3. Can I use any SMTP server with Python Flask and Outlook?

Yes, you can use any SMTP server as long as you have the correct server settings and login credentials. However, it is recommended to use Outlook's SMTP server for better compatibility and security.

4. How do I handle errors while setting up SMTP for emails in Outlook with Python Flask?

You can handle errors by using try-catch blocks and logging any exceptions that may occur during the setup process. Additionally, you can test the SMTP connection and send a test email to ensure that everything is working properly.

5. Is there a limit to the number of emails I can send through SMTP using Python Flask and Outlook?

Yes, there may be a limit to the number of emails you can send through SMTP using Python Flask and Outlook, depending on your Outlook account's settings. It is best to check with your email provider for any limitations and consider using a third-party email service for bulk emails.

Similar threads

  • Programming and Computer Science
Replies
13
Views
3K
  • Programming and Computer Science
Replies
2
Views
1K
Replies
1
Views
1K
  • Programming and Computer Science
Replies
1
Views
791
  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
Replies
5
Views
9K
  • Computing and Technology
Replies
15
Views
1K
  • Programming and Computer Science
Replies
1
Views
2K
  • Programming and Computer Science
Replies
16
Views
1K
  • Computing and Technology
Replies
23
Views
2K
Back
Top