From 1f30ecef02d60322e56f8fd7366036533aae665f Mon Sep 17 00:00:00 2001 From: root Date: Sun, 28 Jan 2018 14:34:49 +0000 Subject: [PATCH] add support for configuring smtpport in callback_mail --- lib/ansible/plugins/callback/mail.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/ansible/plugins/callback/mail.py b/lib/ansible/plugins/callback/mail.py index 3b73d1f974b..3fe75be4792 100644 --- a/lib/ansible/plugins/callback/mail.py +++ b/lib/ansible/plugins/callback/mail.py @@ -25,6 +25,13 @@ options: key: smtphost version_added: '2.5' default: localhost + mtaport: + description: Mail Transfer Agent Port, port at which server SMTP + ini: + - section: callback_mail + key: smtpport + version_added: '2.5' + default: 25 to: description: Mail recipient ini: @@ -76,6 +83,7 @@ class CallbackModule(CallbackBase): self.sender = None self.to = 'root' self.smtphost = os.getenv('SMTPHOST', 'localhost') + self.smtpport = 25 self.cc = None self.bcc = None @@ -86,6 +94,7 @@ class CallbackModule(CallbackBase): self.sender = self.get_option('sender') self.to = self.get_option('to') self.smtphost = self.get_option('mta') + self.smtpport = int(self.get_option('mtaport')) self.cc = self.get_option('cc') self.bcc = self.get_option('bcc') @@ -93,7 +102,7 @@ class CallbackModule(CallbackBase): if body is None: body = subject - smtp = smtplib.SMTP(self.smtphost) + smtp = smtplib.SMTP(self.smtphost, port=self.smtpport) b_sender = to_bytes(self.sender) b_to = to_bytes(self.to)