forked from CodeIt-Bro/Python-Email-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPDFEmail.py
26 lines (20 loc) · 942 Bytes
/
PDFEmail.py
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
import smtplib
import imghdr
from email.message import EmailMessage
Sender_Email = "emailpythontest12345@gmail.com"
Reciever_Email = "codeitbro@gmail.com"
Password = input('Enter your email account password: ')
newMessage = EmailMessage()
newMessage['Subject'] = "Check out the new program PDF"
newMessage['From'] = Sender_Email
newMessage['To'] = Reciever_Email
newMessage.set_content('Let me know what you think. Image attached!')
files = ['LargeElementArray.pdf']
for file in files:
with open(file, 'rb') as f:
file_data = f.read()
file_name = f.name
newMessage.add_attachment(file_data, maintype='application', subtype='octet-stream', filename=file_name)
with smtplib.SMTP_SSL('smtp.gmail.com', 465) as smtp:
smtp.login(Sender_Email, Password)
smtp.send_message(newMessage)