Skip to content

Commit

Permalink
Improve/mailer (#376)
Browse files Browse the repository at this point in the history
* Add option for smtp_port

* Update Mailer.json

* Add smtp_port option
  • Loading branch information
arnydo authored and nadouani committed Dec 20, 2018
1 parent 156bc51 commit ab13a60
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 9 additions & 1 deletion responders/Mailer/Mailer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@
"multi": false,
"required": true,
"defaultValue": "localhost"
},
{
"name": "smtp_port",
"description": "SMTP server port",
"type": "number",
"multi": false,
"required": true,
"defaultValue": "25"
}
]
}
}
4 changes: 3 additions & 1 deletion responders/Mailer/mailer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ def __init__(self):
Responder.__init__(self)
self.smtp_host = self.get_param(
'config.smtp_host', 'localhost')
self.smtp_port = self.get_param(
'config.smtp_port', '25')
self.mail_from = self.get_param(
'config.from', None, 'Missing sender email address')

Expand Down Expand Up @@ -46,7 +48,7 @@ def run(self):
msg['To'] = mail_to
msg.attach(MIMEText(description, 'plain'))

s = smtplib.SMTP(self.smtp_host)
s = smtplib.SMTP(self.smtp_host, self.smtp_port)
s.sendmail(self.mail_from, [mail_to], msg.as_string())
s.quit()
self.report({'message': 'message sent'})
Expand Down

0 comments on commit ab13a60

Please sign in to comment.