mirror of
https://github.com/valitydev/Cortex-Analyzers.git
synced 2024-11-06 17:15:21 +00:00
Improve/mailer (#376)
* Add option for smtp_port * Update Mailer.json * Add smtp_port option
This commit is contained in:
parent
156bc5188d
commit
ab13a60cdd
@ -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"
|
||||
}
|
||||
]
|
||||
}
|
@ -12,6 +12,8 @@ class Mailer(Responder):
|
||||
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')
|
||||
|
||||
@ -46,7 +48,7 @@ class Mailer(Responder):
|
||||
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'})
|
||||
|
Loading…
Reference in New Issue
Block a user