-
Notifications
You must be signed in to change notification settings - Fork 0
/
mail.py
27 lines (22 loc) · 813 Bytes
/
mail.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
27
import smtplib
import json
import os
class MailSystem(object):
def __init__(self):
"""
local version
with open("creditentials.json") as json_file:
data = json.load(json_file)
self.login = data["login"]
self.password = data["password"]
self.receiver_email = data["receiver_email"]
"""
self.login = os.environ.get("login")
self.password = os.environ.get("password")
self.receiver_email = os.environ.get("receiver_email")
smtp = smtplib.SMTP_SSL("smtp.gmail.com", 465)
def send_mail_with_new_offers_num(self, message: str):
self.smtp.ehlo()
self.smtp.login(self.login, self.password)
self.smtp.sendmail(self.login, self.receiver_email, message)
self.smtp.close()