Mailing programatically through Microsoft account

JDias 136 Reputation points
2022-08-02T10:36:29.34+00:00

We have created an email in our account (Microsoft) to send mails programmatically. The mail is of the type npreply@...

How can I send mails programmatically, in order to inform the suppliers of the integration of data, with python smtplib.

My code is:

with SMTP(Connection["Server"],Connection["Port"]) as conn:
conn.ehlo()
conn.starttls()
conn.ehlo()
conn.login(Connection["User"],Connection["Password"])

conn.sendmail(Connection["User"],AllAddrs,msg.as_string())  

print("Message sent!")  

Where Connection["Server"] indicates our MX endpoint and port is 25. User is the noreply@....

This gives error:

line 697, in login
"SMTP AUTH extension not supported by server.")
smtplib.SMTPNotSupportedError: SMTP AUTH extension not supported by server.

Microsoft Authenticator
Microsoft Authenticator
A Microsoft app for iOS and Android devices that enables authentication with two-factor verification, phone sign-in, and code generation.
8,384 questions
0 comments No comments
{count} votes

Accepted answer
  1. Rafael da Rocha 5,251 Reputation points
    2022-08-02T11:48:36.173+00:00

    Basic Auth is now disabled in most tenants.
    Also, if you're connecting to office 365, the smtp for client submission runs on port 587.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. JDias 136 Reputation points
    2022-08-03T15:04:59.443+00:00

    So @Rafael da Rocha , what should I do?

    Connect through port 587 and run the same sequence of commands?

    Where may I find a snippet of code in python (or not)?

    Thanks


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.