1

Im trying to send an email from my regular outlook (or other email server) account in python using the smtplib.However I can only find help on sending from my localhost. Could anyone help me with this?

i have tried many suggestions online but none seem to work.

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
yoni halbe
  • 21
  • 2
  • Does this answer your question? [How to send email to multiple recipients using python smtplib?](https://stackoverflow.com/questions/8856117/how-to-send-email-to-multiple-recipients-using-python-smtplib) – kithuto Feb 07 '23 at 19:30

1 Answers1

1

hey for anyone who this may help i managed to find a solution to the problem, although i dont fully understand the code.

import smtplib

username='yonihalberstadt@outlook.com'
password='******'
mailServer = smtplib.SMTP('smtp-mail.outlook.com', 587)
mailServer.login(username, password)
msg = """
Hello!"""
mailServer.sendmail("yonihalberstadt@outlook.com", 
"yonihalberstadt@outlook.com", msg)

hope this helps anyone with the same problem!

ps: if anyone could explain the followings lines of code to me would be great:

mailServer.ehlo()
mailServer.starttls()
mailServer.ehlo()

thx!

yoni halbe
  • 21
  • 2