Skip to content

Commit 25106c4

Browse files
authored
Create notifications.py
1 parent 2c53338 commit 25106c4

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/notifications.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import smtplib
2+
from email.mime.text import MIMEText
3+
4+
class Notifications:
5+
def __init__(self, smtp_server, smtp_port, username, password):
6+
self.smtp_server = smtp_server
7+
self.smtp_port = smtp_port
8+
self.username = username
9+
self.password = password
10+
11+
def send_email(self, to_email, subject, message):
12+
msg = MIMEText(message)
13+
msg['Subject'] = subject
14+
msg['From'] = self.username
15+
msg['To'] = to_email
16+
17+
with smtplib.SMTP(self.smtp_server, self.smtp_port) as server:
18+
server.login(self.username, self.password)
19+
server.sendmail(self.username, [to_email], msg.as_string())

0 commit comments

Comments
 (0)