Seeking help on SMTP

Hi, I am very new to SMTP. I was doing email automation using python. I got some error in between and stuck.
below is my code

import smtplib
mail = smtplib.SMTP(“Server”,25)
mail.login(userid,password) --> here I get the error

raise SMTPAuthenticationError(code,resp)
SMTPAuthenticationError: (535, b’5.7.3 Authentication Unsuccessful’)

Can anyone help me here? I am using microsoft exchange mail.

So it is hard to know exactly what the issue is here, but assuming the server details are all correct, I have had issues in the past with gmail rejecting the login. On your gmail account there is a setting to allow login from less secure apps which needs to be enabled before this will work. Maybe there is a similar setting for exchange?

Your error indicates your credentials are wrong or you do not have SMTP auth enabled for your account in Exchange.