BUG: cannot send email using outlook
Opened this issue · 1 comments
acbuyan commented
Hi everyone,
I'm having trouble automatically sending emails via my Outlook email address using Python. My organisation has MFA enabled, and I do not believe I can turn it off. The code I use is below:
outlook.username = username
outlook.password = password
print("sending email")
outlook.send(
receivers=["user@example.com"], #NOTE: not email address I'm using, I'm using one that is legitimate
subject="An example",
text="Hi, this is an example."
)
print("email sent")
Expected behavior
I'm expecting to see the printed emails
sending email
email sent
Email provider:
- Email service: Outlook
- Application to view the email (unsure)
Environment (please complete the following information if relevant):
- OS: MacOSX
- Python version 3.11.5
- Red Mail version 0.6.0
congcong009 commented
You may also need to config the smtp information. Better try like this:
from redmail import EmailSender
outlook= EmailSender(host="smtp.office365.com", port=587, username=username, password=password)
outlook.send(
receivers=["user@example.com"], #NOTE: not email address I'm using, I'm using one that is legitimate
subject="An example",
text="Hi, this is an example."
)