Zabbix configure the external mail server to send mail alarms

Source: Internet
Author: User

1. install and configure msmtp

1. Download msmtp

Wget http://downloads.sourceforge.net/msmtp/msmtp-1.4.30.tar.bz2? Big_mirror = 0

2. Extract

Tar-jxvf msmtp-1.4.30.tar.bz2

3. Enter the msmtp directory

Cd msmtp-1.4.30

4. Compile and install

./Configure-prefix =/usr/local/msmtp

Make & make install

5. Configure the msmtp account

Switch to, cd/usr/local/msmtp

Create folder etc, mkdir etc

Use vi to create a file and enter vi/usr/local/msmtp/etc/msmtprc. The edit content is as follows:

# Set default values for all following accounts.

Ults

Logfile/var/log/msmtp. log

# The SMTP server of the provider.

Account service

# SMTP mail server address

Host smtp.qq.com

# Port

Port 25

# Email sent

From xxx@xxx.com

Auth login

# Email server Logon account

User xxx@xxx.com

# Email server login password

Password 123456

# Set a default account

Account default: service

Save and exit.

Because the password is a clear code, we need to modify the permission for this file chmod 600 etc/msmtprc

6. Test

/Usr/local/msmtp/bin/msmtp youremail@test.com

Enter any character and press Ctrl + D to exit and check whether the email is received.

With logs set, you can view logs in/var/log/msmtp. log, and record the failure of sending emails.

Ii. install and configure mutt

1. Install mutt

Yum install mutt-y

2. Edit the mutt configuration file

Vi/etc/Muttrc, edit the overall settings of mutt, and modify the following lines

Set sendmail = "/usr/local/msmtp/bin/msmtp"

Set from = "noreply@XXX.net"

Set use_from = yes

Set realname = noreply@XXX.net

Set editor = "vi"

It is recommended that the Sending address be the same as the account set by msmtp; otherwise, an error may occur. The following operations starting with # can not be performed.

# Vi ~ /. Muttrc: edit the settings in the root directory.

# Set envelope_from = yes

# Set from = "sending email address"

# Set realname = "sender"

# Set use_from = yes

3. Test whether mutt is valid.

Echo "test" | mutt-s "test" test email address

Echo "test" | mutt-s "my_first_test" XX@XXX.com

Zabbix email sending script path

/Maichuang/zabbix/share/zabbix/alertscripts

# Vi/usr/bin/sendalarmemail

Vi/maichuang/zabbix/share/zabbix/alertscripts/sendalarmemail

Add

#! /Bin/bash

Echo "$3" | mutt-s "$2" $1

Modify permissions

Chmod a + x/maichuang/zabbix/share/zabbix/alertscripts/sendalarmemail

3. Configure zabbix to use the external mail server to send alarm emails

1. Go to Administration> Media types

<喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KCjxwPjIu0MK9qE1lZGlhIHR5cGU8L3A + CjxwPiA8aW1nIHNyYz0 = "http://www.2cto.com/uploadfile/Collfiles/20140527/2014052709011636.png" alt = "\">

The configuration is as follows. The Script name must be the same as the name of the Script that sent the email.

3. Go to Configure-> Actions

Create Action

You can modify the default mail content. The following is the modified mail content format:

Add step. Don't forget to click the Add button, click Add next, and click Add below to avoid adding errors. Be sure to select the user who sent the email, and select the Media type name you just defined.

Default operation step duration indicates the number of seconds after the next mail is sent.



I have added actions for sending emails three times in total. If the trigger starts and no one confirms the trigger, the trigger will be sent three times. After the trigger is added, the result is as follows:

4. Go to Administration> Users


To change the admin logon password:


Click Media to add


Type: Select Send alarm email (the previously created Action), and enter the recipient's email address,

At this point, the configuration for sending alarm messages with the external mail server is completed by using a script.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.