aboutsummaryrefslogtreecommitdiff
path: root/gn_auth/smtp.py
diff options
context:
space:
mode:
Diffstat (limited to 'gn_auth/smtp.py')
-rw-r--r--gn_auth/smtp.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/gn_auth/smtp.py b/gn_auth/smtp.py
index 9dc0e5f..2f0e7f4 100644
--- a/gn_auth/smtp.py
+++ b/gn_auth/smtp.py
@@ -41,8 +41,8 @@ def build_email_message(# pylint: disable=[too-many-arguments]
def send_message(# pylint: disable=[too-many-arguments]
- smtp_user: str,# pylint: disable=[unused-argument]
- smtp_passwd: str,# pylint: disable=[unused-argument]
+ smtp_user: str,
+ smtp_passwd: str,
message: EmailMessage,
host: str = "",
port: int = 587,
@@ -54,4 +54,8 @@ def send_message(# pylint: disable=[too-many-arguments]
logging.debug("Email to send:\n******\n%s\n******\n", message.as_string())
with smtplib.SMTP(host, port, local_hostname, timeout, source_address) as conn:
conn.ehlo()
+ if bool(smtp_user) and bool(smtp_passwd):
+ conn.starttls()
+ conn.login(smtp_user, smtp_passwd)
+
conn.send_message(message)