-
Notifications
You must be signed in to change notification settings - Fork 0
/
Email.py
26 lines (21 loc) · 999 Bytes
/
Email.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
from ast import List
from distutils import debug
import smtplib, ssl
from email.mime.text import MIMEText
class Email:
def __init__(self, loginmail, password) -> None:
self.port = 465
self.smtp_server_domain_name = "smtp.gmail.com"
self.loginemail = loginmail
self.password = password
def sendMail(self,to:List,subject,message) -> bool:
try:
with smtplib.SMTP(self.smtp_server_domain_name) as service:
ssl_context = ssl.create_default_context()
service = smtplib.SMTP_SSL(self.smtp_server_domain_name, self.port, context=ssl_context)
service.login(self.loginemail, self.password)
#msg = MIMEText(message)
result = service.sendmail(self.loginemail, to, f"Subject: {subject}\n{message}")
return result
except smtplib.SMTPException as s:
print("Something went wrong...", str(s))