-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
27 lines (23 loc) · 711 Bytes
/
Copy pathapp.py
File metadata and controls
27 lines (23 loc) · 711 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import smtplib
import imaplib
import re
from email.message import EmailMessage
import email
import csv
from O365 import Account
msg = EmailMessage()
my_address = ""
credentials = ("", "")
account = Account(credentials, tenant_id="")
if account.authenticate(scopes=["basic", "message_all"]):
print("Authenticated!") # Let's you know if the authentication was successful
app_generated_password = ""
msg["Subject"] = "The Email Subject"
msg["From"] = my_address
msg["To"] = ""
msg.set_content('Enter Content Here')
with smtplib.SMTP_SSL("smtp.gmail.com", 465) as smtp:
smtp.login(my_address, app_generated_password)
print("Sending mail")
smtp.send_message(msg)
print("Mail has been sent")