-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test suite also for building email Signed-off-by: Petr "Stone" Hracek <[email protected]>
- Loading branch information
Showing
1 changed file
with
8 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,20 +29,23 @@ | |
from typing import List | ||
|
||
|
||
DEFAULT_MAILS = ["[email protected]", "[email protected]"] | ||
|
||
|
||
class EmailSender: | ||
|
||
def __init__(self, recipient_email: List[str]): | ||
def __init__(self, recipient_email: List[str] = None): | ||
self.recipient_email = recipient_email | ||
self.mime_msg = MIMEMultipart() | ||
|
||
def send_email(self, subject_msg, body: List[str]): | ||
def send_email(self, subject_msg, body: List[str] = None): | ||
send_from = "[email protected]" | ||
send_to = self.recipient_email | ||
print(body) | ||
send_to = DEFAULT_MAILS | ||
if self.recipient_email is not None: | ||
send_to.extend(self.recipient_email) | ||
whole_body = "".join(body) | ||
msg = ("<html><head><style>table, th, td {border: 1px solid black;}</style></head>" | ||
f"<body>{whole_body}</body></html>") | ||
print(msg) | ||
self.mime_msg["From"] = send_from | ||
self.mime_msg["To"] = ", ".join(send_to) | ||
self.mime_msg["Subject"] = subject_msg | ||
|