No success setting up notifications

Package: crowdsec
Version: 1.6.8

Trying to set up email notification.

cscli notifications list
───────────────────────────────────────────────────────────────────────────────────────
 Active  Name              Type      Profile name                                      
───────────────────────────────────────────────────────────────────────────────────────
 ✔️      email_default     email     default_ip_remediation, default_range_remediation 
 🚫      file_default      file                                                        
 🚫      http_default      http                                                        
 🚫      sentinel_default  sentinel                                                    
 🚫      slack_default     slack                                                       
 🚫      splunk_default    splunk

When running

systemctl restart crowdsec

I get

Job for crowdsec.service failed because the control process exited with error code.
See "systemctl status crowdsec.service" and "journalctl -xeu crowdsec.service" for details.
journalctl -xeu crowdsec.service
...
Apr 30 11:58:53 <masked> crowdsec[26464]: FATAL api server init: unable to run plugin broker: while loading plugin: while configuring email_default: rpc error: code = Unknown desc = yaml: unmarshal errors:
Apr 30 11:58:53 <masked> crowdsec[26464]:   line 18: cannot unmarshal !!str `markus....` into []string
Apr 30 11:58:53 <masked> systemd[1]: crowdsec.service: Control process exited, code=exited, status=1/FAILURE
...

I tried to use none, single or double quotes to set the appropriate values in

/etc/crowdsec/notifications/email.yaml

Nothing helped.

Any reply would be greatly appreciated.
thx

fyi

cscli notifications test email_default
DEBU[0000] starting plugin                               args="[/usr/lib/crowdsec/plugins/notification-email]" path=/usr/lib/crowdsec/plugins/notification-email
DEBU[0000] plugin started                                path=/usr/lib/crowdsec/plugins/notification-email pid=32476
DEBU[0000] waiting for RPC address                       path=/usr/lib/crowdsec/plugins/notification-email
DEBU[0000] using plugin                                  version=1
TRAC[0000] waiting for stdio data                       
Error: while loading plugin: while configuring email_default: rpc error: code = Unknown desc = yaml: unmarshal errors:
  line 18: cannot unmarshal !!str `markus....` into []string

seem your email.yaml is incorrect, it seems the contact addresses is a string when it needs to be an array of strings like:

wrong

receiver_emails: "myemail@domain.tld"

right

receiver_emails:
  - "myemail@domain.tld"

thx @iiAmLoz for taking time

This does it :slight_smile:

CrowdSec starts without errors.

But when testing it throws

cscli notifications test email_default
DEBU[0000] starting plugin                               args="[/usr/lib/crowdsec/plugins/notification-email]" path=/usr/lib/crowdsec/plugins/notification-email
DEBU[0000] plugin started                                path=/usr/lib/crowdsec/plugins/notification-email pid=53410
DEBU[0000] waiting for RPC address                       path=/usr/lib/crowdsec/plugins/notification-email
DEBU[0000] using plugin                                  version=1
TRAC[0000] waiting for stdio data                       
INFO registered plugin email_default              
INFO pluginTomb dying                             
ERROR rpc error: code = Unknown desc = Mail Error: SMTP Connection timed out error, retry num 1  plugin=email_default
ERROR rpc error: code = Unknown desc = Mail Error: SMTP Connection timed out  plugin:=email_default
INFO killing all plugins                          
DEBU[0011] received EOF, stopping recv loop              err="rpc error: code = Unavailable desc = error reading from server: EOF"
INFO[0011] plugin process exited                         path=/usr/lib/crowdsec/plugins/notification-email pid=53410
DEBU[0011] plugin exited

cheers

That error is stating the email setting are not working for connection timeout, ensure the settings you are using are correct such as hostname and port

thx @iiAmLoz

Now working as expected

cscli notifications test email_default
DEBU[0000] starting plugin                               args="[/usr/lib/crowdsec/plugins/notification-email]" path=/usr/lib/crowdsec/plugins/notification-email
DEBU[0000] plugin started                                path=/usr/lib/crowdsec/plugins/notification-email pid=69993
DEBU[0000] waiting for RPC address                       path=/usr/lib/crowdsec/plugins/notification-email
DEBU[0000] using plugin                                  version=1
TRAC[0000] waiting for stdio data                       
INFO registered plugin email_default              
INFO pluginTomb dying                             
INFO[0000] sent email to [masked]      @module=email-plugin.email_default
INFO killing all plugins                          
DEBU[0000] received EOF, stopping recv loop              err="rpc error: code = Unavailable desc = error reading from server: EOF"
INFO[0000] plugin process exited                         path=/usr/lib/crowdsec/plugins/notification-email pid=69993
DEBU[0000] plugin exited