-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathptsmtplib.py
22 lines (19 loc) · 891 Bytes
/
ptsmtplib.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import smtplib
import ssl
import base64
import configparser
class Chaldea(object):
def __init__(self, *args, **kawgs):
self.config = configparser.ConfigParser()
self.config.read('configuration.ini')
self.smtp_server = self.config['connection']['server']
self.port = self.config['connection']['port']
self.user = self.config['credentials']['user']
self.password = self.config['credentials']['password']
self.recipient = {_ for _ in args}
def send_message(self, message:str):
"""Connects to smtp server to send notification, alarms, and analysis reports."""
context = ssl.create_default_context()
with smtplib.SMTP_SSL(self.smtp_server, self.port, context=context) as self.server:
self.server.login(self.user, password)
self.server.sendmail(self.user, self.recipient, message)