Skip to content
Snippets Groups Projects
Commit 8770567b authored by Robert Goldmann's avatar Robert Goldmann
Browse files

BaseUtils: MailHandler: don't send mail multiple times if multiple receivers...

BaseUtils: MailHandler: don't send mail multiple times if multiple receivers are registered (v1.1.1)
parent 6e6fdc57
No related branches found
No related tags found
No related merge requests found
...@@ -18,8 +18,7 @@ class MailHandler: ...@@ -18,8 +18,7 @@ class MailHandler:
@staticmethod @staticmethod
def send(host: str, port: int, userName: str, password: str, receiverMails: List[str], subject: str, content: str): def send(host: str, port: int, userName: str, password: str, receiverMails: List[str], subject: str, content: str):
for receiver in receiverMails: message = MailHandler.__create_message(userName, receiverMails, subject, content)
message = MailHandler.__create_message(userName, receiver, subject, content)
# Create secure connection with server and send email # Create secure connection with server and send email
context = ssl.create_default_context() context = ssl.create_default_context()
...@@ -28,11 +27,11 @@ class MailHandler: ...@@ -28,11 +27,11 @@ class MailHandler:
server.sendmail(userName, receiverMails, message.as_string()) server.sendmail(userName, receiverMails, message.as_string())
@staticmethod @staticmethod
def __create_message(userName: str, receiver: str, subject: str, content: str) -> MIMEMultipart: def __create_message(userName: str, receiverMails: List[str], subject: str, content: str) -> MIMEMultipart:
message = MIMEMultipart('alternative') message = MIMEMultipart('alternative')
message['Subject'] = subject message['Subject'] = subject
message['From'] = userName message['From'] = userName
message['To'] = receiver message['To'] = ', '.join(receiverMails)
# Create the plain-text and HTML version of your message # Create the plain-text and HTML version of your message
text = subject text = subject
......
...@@ -3,7 +3,7 @@ from setuptools import setup ...@@ -3,7 +3,7 @@ from setuptools import setup
setup( setup(
name='TheCodeLabs-BaseUtils', name='TheCodeLabs-BaseUtils',
packages=['TheCodeLabs_BaseUtils'], packages=['TheCodeLabs_BaseUtils'],
version='1.1.0', version='1.1.1',
license='MIT', license='MIT',
description='Useful python classes', description='Useful python classes',
author='TheCodeLabs', author='TheCodeLabs',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment