-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmanageMail.py
More file actions
30 lines (20 loc) · 728 Bytes
/
manageMail.py
File metadata and controls
30 lines (20 loc) · 728 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
from email import message
import smtplib
from email.message import EmailMessage
import easyimap as e
class initialise:
def __init__(self,email, password):
self.password = password
self.email = email
def readMail(self):
server = e.connect("imap.gmail.com",self.email,self.password)
print(server.mail(server.listids()[0]).body)
def sendMail(self,Subject, To, Body):
msg = EmailMessage()
msg['From'] = self.email
msg["Subject"] = Subject
msg["To"] = To
msg.set_content(Body)
with smtplib.SMTP_SSL('smtp.gmail.com',465) as smtp:
smtp.login(self.email,self.password)
smtp.send_message(msg)