Skip to content
Snippets Groups Projects
Commit 8ef2a68d authored by Jan Mach's avatar Jan Mach
Browse files

Fixed bugs in development mailing subroutine.

(Redmine issue: #7041)
parent c1def309
No related branches found
No related tags found
No related merge requests found
...@@ -166,7 +166,7 @@ class MailerPlugin(pyzenkit.baseapp.ZenAppPlugin): ...@@ -166,7 +166,7 @@ class MailerPlugin(pyzenkit.baseapp.ZenAppPlugin):
proc.communicate(bytes(email.as_string(), 'UTF-8')) proc.communicate(bytes(email.as_string(), 'UTF-8'))
@staticmethod @staticmethod
def mail_smtplib(email): def mail_smtplib(email, server, port):
""" """
Send given email via smtplib. Send given email via smtplib.
...@@ -176,9 +176,9 @@ class MailerPlugin(pyzenkit.baseapp.ZenAppPlugin): ...@@ -176,9 +176,9 @@ class MailerPlugin(pyzenkit.baseapp.ZenAppPlugin):
'return-path', 'return-path',
email.get_header('from') email.get_header('from')
) )
s = self.get_application().c(self.CONFIG_MAIL_DEV_SERVER) server = server or 'localhost'
p = self.get_application().c(self.CONFIG_MAIL_DEV_PORT) port = port or 25
with smtplib.SMTP(s, p) as smtp: with smtplib.SMTP(server, port) as smtp:
smtp.send_message(email, from_addr = envelope_from) smtp.send_message(email, from_addr = envelope_from)
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
...@@ -242,8 +242,12 @@ class MailerPlugin(pyzenkit.baseapp.ZenAppPlugin): ...@@ -242,8 +242,12 @@ class MailerPlugin(pyzenkit.baseapp.ZenAppPlugin):
msg = email_class(email_headers, **email_params) msg = email_class(email_headers, **email_params)
if self.get_application().c(self.CONFIG_MAIL_DEV_MODE): if self.get_application().c(self.CONFIG_MAIL_DEV_MODE):
self.mail_smtplib(msg) self.mail_smtplib(
else msg,
self.get_application().c(self.CONFIG_MAIL_DEV_SERVER),
self.get_application().c(self.CONFIG_MAIL_DEV_PORT)
)
else:
self.mail_sendmail(msg) self.mail_sendmail(msg)
return msg return msg
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment