0

I have this python program that sends me daily emails. This is my personal email account with Microsoft outlook.com. My code has been working fine but broke yesterday. Here is my code

    def email(subject, text):
        import smtplib
        from email.mime.multipart import MIMEMultipart
        from email.mime.text import MIMEText
        from email.mime.image import MIMEImage
        user = "[email protected]"
        passwd = "xxxxxx"
        sender = '[email protected]'
        receiver = '[email protected]'
        msg = MIMEMultipart('mixed')
        msg['Subject'] = subject
        msg['From'] = '[email protected]'
        msg['To'] = '[email protected]'
        text_plain = MIMEText(text,'plain','utf-8')
        msg.attach(text_plain)
        server = smtplib.SMTP('smtp.office365.com', 587)
        server.ehlo()
        server.starttls()
        server.login(user, passwd)
        server.sendmail(sender, receiver, msg.as_string())
        server.quit()

User, sender, receiver, to and from are all the same email address. When I run the script, I got this error

    >>> email('test subject', 'test message')
     File "<stdin>", line 1, in <module>
     File "<stdin>", line 19, in email
     File "/usr/lib/python3.6/smtplib.py", line 730, in login
       raise last_exception
     File "/usr/lib/python3.6/smtplib.py", line 721, in login
       initial_response_ok=initial_response_ok)
     File "/usr/lib/python3.6/smtplib.py", line 642, in auth
       raise SMTPAuthenticationError(code, resp)
     smtplib.SMTPAuthenticationError: (535, b'5.7.3 Authentication unsuccessful [MW4PR03CA0229.namprd03.prod.outlook.com]')

Any ideas what could go wrong? This script has been working for at least half year.. Thanks! Difan

1 Answer 1

1

not sure if I'll be of any help but since yesterday we are having problems with thunderbird connecting to microsoft mail server. For the base account changing authentication method to OAuth2 helped, but I still don't know what to do about aliases. So I guess the problem lies with microsoft changing the requierements for authentication.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.