Skip to content

Commit

Permalink
Let's define default mails.
Browse files Browse the repository at this point in the history
Add test suite also for building email

Signed-off-by: Petr "Stone" Hracek <[email protected]>
  • Loading branch information
phracek committed Nov 6, 2024
1 parent 7f5b747 commit 54f9c0f
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions auto_merger/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 54f9c0f

Please sign in to comment.