SMTP Correct Office365 Setup to send emails through python script

Job ID: 35588387

Budget: €30 – €250 EUR

Hi,

I am searching for a freelancer to guide me this weekend through the correct setup for Office365 to access the SMTP server. Right now I constantly get could not authenticate in my script externally. I have verified in admin panel that SMTP is available.

The script I am using is the following:

""""
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText

# ipchicken.com
# https://admin.exchange.microsoft.com/#/connectors

username = ""
password = ""
mail_from = ""
mail_to = ""
mail_subject = "Test Subject"
mail_body = "This is a test message"

mimemsg = MIMEMultipart()
mimemsg['From']=mail_from
mimemsg['To']=mail_to
mimemsg['Subject']=mail_subject
mimemsg.attach(MIMEText(mail_body, 'plain'))

connection = smtplib.SMTP_SSL(host='smtp.office365.com', port=587)
connection.set_debuglevel(1)
connection.ehlo()

connection.starttls()
connection.login(username, password)

connection.sendmail(username, [""], mimemsg.as_string())
connection.quit()
""""

If you think you are experienced and have worked to configure SMTP in Office365 before start the bid with the phrase office365 config. Budget is 50 Euros and should be a quick job for someone experienced. Ideally guiding me for 30 mins through the correct setup.

Thanks and happy bidding :)
Related categories: Python System Admin Microsoft Exchange Office 365 SMTP