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

后端 未结 4 1290
时光取名叫无心
时光取名叫无心 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:10

    The code has slightly changed. The above code won't work. Please use the below code. Reference

    from O365 import Account
    
    credentials = ('client_id', 'client_secret')
    
    account = Account(credentials)
    m = account.new_message()
    m.to.add('to_example@example.com')
    m.subject = 'Testing!'
    m.body = "George Best quote: I've stopped drinking, but only while I'm asleep."
    m.send()
    

提交回复
热议问题