How to send SMTP email for office365 with python using tls/ssl

后端 未结 4 1292
时光取名叫无心
时光取名叫无心 2021-02-01 06:25

I am trying to send an email from my office365 corporate account using python. I am new to python. This code previously worked when using my hotmail account, however now that I

4条回答
  •  天命终不由人
    2021-02-01 07:30

    Most likely, the problem is not in your code, but in the Exchange Online configuration.

    I bet 535 5.7.3 Authentication unsuccessful is thrown because authenticated SMTP (SMTP AUTH protocol) is disabled in your Exchange Online organization.

    Here you can find my answer explaining how you can enable SMTP AUTH for the user you are sending emails from. You have to be an Office 365 org admin to do that, or you can ask your administrator for help.

    After that mailserver.starttls() should work. Notice that you don't need to specify a certificate in that call.

提交回复
热议问题