Some important service:
[Unit] ... OnFailure=status-email@%n.service [Unit] Description=status email for %i to user [Service] Type=oneshot ExecStart=/usr/local/bin/systemd-email.sh <recipient> %i User=root Group=systemd-journal [Install] WantedBy=multi-user.target I'm getting error systemd-email.sh[117310]: ssmtp: Cannot open smtp.gmail.com:587
I can send mail manually ./systemd-email.sh $RECIPIENT $SERVICE_NAME
It's also working as cronjob.
My /etc/ssmtp/ssmtp.conf:
root=<gmail address> mailhub=smtp.gmail.com:465 FromLineOverride=YES AuthUser=<gmail address> AuthPass=<password> UseTLS=YES Why cron can send mail in this setup but systemd cannot?
systemd-email.sh[117310]: ssmtp: Cannot open smtp.gmail.com:587and later,mailhub=smtp.gmail.com:465. Something is mis-configured in the first case to use port 587 instead of the correct port 465./etc/ssmtp/revaliasesI left wrong ports...root:[email protected]:smtp.gmail.com:587 mainuser:[email protected]:smtp.gmail.com:587. Changed them to 465 and it's all working now.