3

I am trying to follow the steps below. But there is no sendEmail on CentOS 7. I have looked at a few alternatives like Postfix, but I am not sure of the script commands.

Alternatively you can use sendEmail.

1) apt-get install sendEmail

2) Create a script "zabbix_sendemail" (chmod 755) in the AlertScriptsPath folder specified by /etc/zabbix/zabbix_server.conf

> #!/bin/sh
>
> export smtpemailfrom=zabbix@yourdomain.com export zabbixemailto=$1
> export zabbixsubject=$2 export zabbixbody=$3 export
> smtpserver=yoursmtpserver.com export smtplogin=smtpuser export
> smtppass=smtppassword
>
> /usr/bin/sendEmail -f $smtpemailfrom -t $zabbixemailto -u
> $zabbixsubject -m $zabbixbody -s $smtpserver:25 -xu $smtplogin -xp
> $smtppass

3) Set the Action (Configurations / Actions in the php frontend)

4) Set the Media Type (Administration / Media types in the php frontend) script to zabbix_sendemail

5) Add the Media to the user (Administration / Users / user in php frontend) Reply With Quote

From https://www.zabbix.com/forum/showthread.php?t=1323

Peter Mortensen
  • 2,319
  • 5
  • 23
  • 24
GodAtum
  • 317
  • 1
  • 3
  • 10
  • You could wait for [Zabbix 3.0](https://www.zabbix.com/documentation/3.0/manual/config/notifications/media/email), which does support SMTP auth. - Rather than using a shell script to send email, [configure Zabbix 2.x](https://www.zabbix.com/documentation/2.4/manual/config/notifications/media/email) to use `localhost` and [configure Postfix to authenticate](https://www.dnsexit.com/support/mailrelay/postfix.html) to the relay server instead. – HBruijn Aug 28 '15 at 12:08

4 Answers4

6

You should install mailx (yum install mailx).

It looks like you can probably replace the script with this:

#!/bin/sh
echo "$3" | /bin/mailx \
-r zabbix@yourdomain.example \
-s "$2" \
-S smtp="yoursmtpserver.example:25" \
-S smtp-auth=login \
-S smtp-auth-user="your-user" \
-S smtp-auth-password="your-password" \
"$1"

Consider using port 587 (submission) for such messages if they are always delivered directly to the delivery MTA (i.e. the last one). Otherwise, check out the manpage for ways to use STARTTLS to protect your password.

The example writers should feel shame for not quoting their shell variables...

I think centos puts mailx at /bin/mailx, but it might also be in /usr/bin/mailx.

Falcon Momot
  • 24,975
  • 13
  • 61
  • 92
2

Sendemail is a Perl script, so it is easy to install anywhere there is Perl. The upstream URL is http://www.caspian.dotconf.net/menu/Software/SendEmail/, and they have prepacaged rpms. It has nothing to do with Postfix.

Peter Mortensen
  • 2,319
  • 5
  • 23
  • 24
hildred
  • 216
  • 1
  • 3
  • 8
0

I assume that your 'sendEmail' is just Sendmail. Postfix has its own /usr/sbin/sendmail binary, which should work with pretty much any sendmail-compatible package.

As I see, you want to forward your mail to a remote SMTP server. Zabbix natively supports SMTP connectivity, so why not use the built-in mechanism instead of calling the sendmail binary?

Peter Mortensen
  • 2,319
  • 5
  • 23
  • 24
sam_pan_mariusz
  • 2,053
  • 1
  • 12
  • 15
0

For CentOs, the combination of postfix and sendemail works well. Remember to start the postfix service before you sendemail.

To stay safe, please ensure

mynetworks_style = host

in /etc/postfix/main.cnf