CVN-92
CVN-92

Reputation: 21

Email sending error in elastalert. SMTPSenderRefused: (530, '5.5.1 Authentication Required)

i got gmail authentication error. my config and error message as below I already allowed less secure apps in gmail.

Config.yaml file email section as below

 name: frequency_rule
 type: frequency
 index: security
 num_events: 50

 timeframe:
   days: 1

 filter:
   - term:
       host.keyword : "azure-2"
 alert:
   - email
 email:
   "[email protected]"

 smtp_host: "smtp.gmail.com"
 smtp_port: "465"
 smtp_ssl: true
 from_addr: "[email protected]"
 user: "[email protected]"
 password: "password"

Error message as below

PS C:\Users\smiforce-2ndPC\Downloads\Compressed\elastalert-master\elastalert-master> python -m elastalert.elastalert --verbose --config ./config.yaml --rule ./alert_rules/frequency4.yaml
INFO:elastalert:Starting up
INFO:elastalert:Queried rule frequency_rule4 from 2017-11-20 09:48 Central Standard Time to 2017-11-21 09:48 Central Standard Time: 24 / 24 hits
ERROR:root:Traceback (most recent call last):
File "C:\Users\smiforce-2ndPC\Downloads\Compressed\elastalert-master\elastalert-master\elastalert\elastalert.py", line 1246, in alert
return self.send_alert(matches, rule, alert_time=alert_time, retried=retried)
File "C:\Users\smiforce-2ndPC\Downloads\Compressed\elastalert-master\elastalert-master\elastalert\elastalert.py", line 1326, in send_alert
alert.alert(matches)
File "elastalert\alerts.py", line 451, in alert
self.smtp.sendmail(self.from_addr, to_addr, email_msg.as_string())
File "C:\Python27\lib\smtplib.py", line 737, in sendmail
raise SMTPSenderRefused(code, resp, from_addr)
SMTPSenderRefused: (530, '5.5.1 Authentication Required. Learn more at\n5.5.1 https://support.google.com/mail/?p=WantAuthError l4sm636961ioc.69 - gsmtp', '[email protected]')

ERROR:root:Uncaught exception running rule frequency_rule4: (530, '5.5.1 Authentication Required. Learn more at\n5.5.1 https://support.google.com/mail/?p=WantAuthError l4sm636961ioc.69 - gsmt

Upvotes: 2

Views: 1455

Answers (1)

Val
Val

Reputation: 217344

The user and password fields should not be stored in the same config.yaml file but in another file which is referenced in config.yaml.

For instance, create another file named auth.yaml and add the user and password configuration into it:

user: "[email protected]"
password: "password"

Then in config.yaml you can reference that file using this setting:

smtp_auth_file: "/path/to/auth.yaml"

Upvotes: 2

Related Questions