Mail notifications not working

It seems GCP is blocking mail sent via mailx. Is it possible to configure icinga to send mail notifications via external SMTP server?

my /var/log/mail.log file have a lot of messages like this:

Jan  3 08:52:01 monitor sm-mta[24812]: 0BTHL6MC031190:, delay=4+02:20:01, xdelay=00:10:55, mailer=esmtp, pri=26580000, [], dsn=4.0.0, stat=Deferred: Connection timed out with
Jan  3 09:02:01 monitor sm-mta[26970]: 101Hp6MC012549:, delay=1+02:00:00, xdelay=00:10:55, mailer=esmtp, pri=7050000, [], dsn=4.0.0, stat=Deferred: Connection timed out with

From some research about this, I created a file /root/.mailrc with the content below:

set smtp-use-starttls
set ssl-verify=ignore
set smtp=smtp://
set smtp-auth=login
set smtp-auth-password=MY*PASS
set from="Icinga Monitor <>"

installed s-nail and adjust the line in file /etc/icinga2/scripts/


but mail notifications still don’t work.
Any help would be appreciated

Icinga sends emails via whatever MTA you have configured on the machine.

Try something like sSMTP as a dumb relay to send via an external server which
Google likes (but good luck with that - Google is getting pretty unfriendly
about accepting email these days).


Or to put it more simply:
Icinga runs only a external script for notification. What the script is doing, is up to you. If you install icinga, the setup routine copy two scripts into /etc/icinga2/scripts. You can use these one or you write your own script, use an other program or whatever.
We for example are using our own python script.

Hello @ronanlucio,
You can use mailx to send by smtp. Use the switch “-S smtp=“mysmtpserver””. I am able to send notification through the company (internal) smtp server this way

I hope this helps.

Hi @aclark6996, good one.
Do you mean adding it into /etc/icinga2/scripts?

MAILBIN="mail -S smtp=\"\""

something like this?

Thank you @stevie-sy, sounds good

1 Like

No, keep the MAILBIN variable the same. Add the -S switch at the bottom of the standard Icinga notification scripts (/etc/icinga2/scrips/ You will need to edit it for your Linux version.

/usr/bin/printf "%b" "$NOTIFICATION_MESSAGE" | $MAILBIN -r "$MAILFROM" -s "$SUBJECT" -S smtp="" $USEREMAIL


Hi, thank you all for your helpful ideas.

What solved my issue in a fancy and fast way was Antony’s suggestion for installing an MTA to send messages using a third-party SMTP server.