文章目录
- 请参考NETDATA
- 这个没啥好说的!我自己用域名搭建了了一个邮件服务器!如果是其它邮件请自行搜索!这里的配置是不能有SSL协议的,docker里面的cert有问题! 私人邮箱搭建教程
- 注意替换为你自己服务器分配的CONTAINER ID docker ps docker exec -it bab6e102f429 /bin/bash
-
- vi /root/.msmtprc 配置文件参考(请按照配置说明和自己服务器情况自行更改,不要做只会从copy的脑残)如下: 原参考地址https://marlam.de/msmtp/msmtprc.txt # Example for a user configuration file ~/.msmtprc # # This file focusses on TLS and authentication. Features not used here include # logging, timeouts, SOCKS proxies, TLS parameters, Delivery Status Notification # (DSN) settings, and more. # Set default values for all following accounts. defaults # Use the mail submission port 587 instead of the SMTP port 25. port 587 # Always use TLS. tls on # Set a list of trusted CAs for TLS. The default is to use system settings, but # you can select your own file. #tls_trust_file /etc/ssl/certs/ca-certificates.crt # A freemail service account freemail # Host name of the SMTP server host smtp.freemail.example # As an alternative to tls_trust_file, you can use tls_fingerprint # to pin a single certificate. You have to update the fingerprint when the # server certificate changes, but an attacker cannot trick you into accepting # a fraudulent certificate. Get the fingerprint with # $ msmtp --serverinfo --tls --tls-certcheck=off --host=smtp.freemail.example #tls_fingerprint 00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF:00:11:22:33 # Envelope-from address from [email protected] # Authentication. The password is given using one of five methods, see below. auth on user joe.smith # Password method 1: Add the password to the system keyring, and let msmtp get # it automatically. To set the keyring password using Gnome's libsecret: # $ secret-tool store --label=msmtp \ # host smtp.freemail.example \ # service smtp \ # user joe.smith # Password method 2: Store the password in an encrypted file, and tell msmtp # which command to use to decrypt it. This is usually used with GnuPG, as in # this example. Usually gpg-agent will ask once for the decryption password. passwordeval gpg2 --no-tty -q -d ~/.msmtp-password.gpg # Password method 3: Store the password directly in this file. Usually it is not # a good idea to store passwords in cleartext files. If you do it anyway, at # least make sure that this file can only be read by yourself. #password secret123 # Password method 4: Store the password in ~/.netrc. This method is probably not # relevant anymore. # Password method 5: Do not specify a password. Msmtp will then prompt you for # it. This means you need to be able to type into a terminal when msmtp runs. # A second mail address at the same freemail service account freemail2 : freemail from [email protected] # The SMTP server of your ISP account isp host mail.isp.example from [email protected] auth on user 12345 # Set a default account account default : freemail 我的配置 defaults port 465 tls off account freemail host xxx. from [email protected] auth login # 这里不能用on,否则会报错 user [email protected] password xxxxxxxxxx account default : freemail
- msmtp [email protected] 请注意替换为你收件邮箱,回车后输入发送内容,按CTRL+D发送。若邮件接收成功则配置成功,若失败则有相关提示信息!
- 修改配置文件 vi /etc/netdata/health_alarm_notify.conf 把sendmail的参数指向msmtp sendmail="/usr/bin/msmtp" 配置收件人信息 | 如下图 更改msmtprc的文件权限 chmod 600 ~/.msmtprc
- 如收到相关邮件则配置成功! # enable debugging info on the console export NETDATA_ALARM_NOTIFY_DEBUG=1 # send test alarms to sysadmin /usr/libexec/netdata/plugins.d/alarm-notify.sh test # send test alarms to any role /usr/libexec/netdata/plugins.d/alarm-notify.sh test "ROLE"
- 经过一晚上的观察,发现邮件提醒虽然测试能够使用,但实际没法正常工作,后续找到了解决办法!具体原因不详,都弄一下吧! 参考地址 | https://github.com/netdata/netdata/issues/5721 以root身份进入docker docker exec -it --user root <container id> /bin/bash 更改配置文件为644(官方教程为600,具体没测试) chmod 644 ~/.msmtprc 复制配置文件 cp ~/.msmtprc /etc/msmtprc

自己上午搭建好NETDATA并配置好Telegram预警后就尝试了一下配置EMAIL,教程如下!
- 我这里用的DOCKER搭建的,如非docker以下教程仅作参考!
-
官网参考地址 | https://learn.netdata.cloud/docs/agent/health/notifications/email
请参考NETDATA
请参考NETDATA
这个没啥好说的!我自己用域名搭建了了一个邮件服务器!如果是其它邮件请自行搜索!这里的配置是不能有SSL协议的,docker里面的cert有问题!
这个没啥好说的!我自己用域名搭建了了一个邮件服务器!如果是其它邮件请自行搜索!这里的配置是不能有SSL协议的,docker里面的cert有问题!
注意替换为你自己服务器分配的CONTAINER ID
docker ps
docker exec -it bab6e102f429 /bin/bash
注意替换为你自己服务器分配的CONTAINER ID
docker ps
docker exec -it bab6e102f429 /bin/bash

vi /root/.msmtprc
- 配置文件参考(请按照配置说明和自己服务器情况自行更改,不要做只会从copy的脑残)如下:
# Example for a user configuration file ~/.msmtprc
#
# This file focusses on TLS and authentication. Features not used here include
# logging, timeouts, SOCKS proxies, TLS parameters, Delivery Status Notification
# (DSN) settings, and more.
# Set default values for all following accounts.
defaults
# Use the mail submission port 587 instead of the SMTP port 25.
port 587
# Always use TLS.
tls on
# Set a list of trusted CAs for TLS. The default is to use system settings, but
# you can select your own file.
#tls_trust_file /etc/ssl/certs/ca-certificates.crt
# A freemail service
account freemail
# Host name of the SMTP server
host smtp.freemail.example
# As an alternative to tls_trust_file, you can use tls_fingerprint
# to pin a single certificate. You have to update the fingerprint when the
# server certificate changes, but an attacker cannot trick you into accepting
# a fraudulent certificate. Get the fingerprint with
# $ msmtp --serverinfo --tls --tls-certcheck=off --host=smtp.freemail.example
#tls_fingerprint 00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF:00:11:22:33
# Envelope-from address
from [email protected]
# Authentication. The password is given using one of five methods, see below.
auth on
user joe.smith
# Password method 1: Add the password to the system keyring, and let msmtp get
# it automatically. To set the keyring password using Gnome's libsecret:
# $ secret-tool store --label=msmtp \
# host smtp.freemail.example \
# service smtp \
# user joe.smith
# Password method 2: Store the password in an encrypted file, and tell msmtp
# which command to use to decrypt it. This is usually used with GnuPG, as in
# this example. Usually gpg-agent will ask once for the decryption password.
passwordeval gpg2 --no-tty -q -d ~/.msmtp-password.gpg
# Password method 3: Store the password directly in this file. Usually it is not
# a good idea to store passwords in cleartext files. If you do it anyway, at
# least make sure that this file can only be read by yourself.
#password secret123
# Password method 4: Store the password in ~/.netrc. This method is probably not
# relevant anymore.
# Password method 5: Do not specify a password. Msmtp will then prompt you for
# it. This means you need to be able to type into a terminal when msmtp runs.
# A second mail address at the same freemail service
account freemail2 : freemail
from [email protected]
# The SMTP server of your ISP
account isp
host mail.isp.example
from [email protected]
auth on
user 12345
# Set a default account
account default : freemail
- 我的配置
defaults
port 465
tls off
account freemail
host xxx.
from [email protected]
auth login # 这里不能用on,否则会报错
user [email protected]
password xxxxxxxxxx
account default : freemail
vi /root/.msmtprc
# Example for a user configuration file ~/.msmtprc
#
# This file focusses on TLS and authentication. Features not used here include
# logging, timeouts, SOCKS proxies, TLS parameters, Delivery Status Notification
# (DSN) settings, and more.
# Set default values for all following accounts.
defaults
# Use the mail submission port 587 instead of the SMTP port 25.
port 587
# Always use TLS.
tls on
# Set a list of trusted CAs for TLS. The default is to use system settings, but
# you can select your own file.
#tls_trust_file /etc/ssl/certs/ca-certificates.crt
# A freemail service
account freemail
# Host name of the SMTP server
host smtp.freemail.example
# As an alternative to tls_trust_file, you can use tls_fingerprint
# to pin a single certificate. You have to update the fingerprint when the
# server certificate changes, but an attacker cannot trick you into accepting
# a fraudulent certificate. Get the fingerprint with
# $ msmtp --serverinfo --tls --tls-certcheck=off --host=smtp.freemail.example
#tls_fingerprint 00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF:00:11:22:33
# Envelope-from address
from [email protected]
# Authentication. The password is given using one of five methods, see below.
auth on
user joe.smith
# Password method 1: Add the password to the system keyring, and let msmtp get
# it automatically. To set the keyring password using Gnome's libsecret:
# $ secret-tool store --label=msmtp \
# host smtp.freemail.example \
# service smtp \
# user joe.smith
# Password method 2: Store the password in an encrypted file, and tell msmtp
# which command to use to decrypt it. This is usually used with GnuPG, as in
# this example. Usually gpg-agent will ask once for the decryption password.
passwordeval gpg2 --no-tty -q -d ~/.msmtp-password.gpg
# Password method 3: Store the password directly in this file. Usually it is not
# a good idea to store passwords in cleartext files. If you do it anyway, at
# least make sure that this file can only be read by yourself.
#password secret123
# Password method 4: Store the password in ~/.netrc. This method is probably not
# relevant anymore.
# Password method 5: Do not specify a password. Msmtp will then prompt you for
# it. This means you need to be able to type into a terminal when msmtp runs.
# A second mail address at the same freemail service
account freemail2 : freemail
from [email protected]
# The SMTP server of your ISP
account isp
host mail.isp.example
from [email protected]
auth on
user 12345
# Set a default account
account default : freemail
defaults
port 465
tls off
account freemail
host xxx.
from [email protected]
auth login # 这里不能用on,否则会报错
user [email protected]
password xxxxxxxxxx
account default : freemail
msmtp [email protected]
请注意替换为你收件邮箱,回车后输入发送内容,按CTRL+D发送。若邮件接收成功则配置成功,若失败则有相关提示信息!
msmtp [email protected]
请注意替换为你收件邮箱,回车后输入发送内容,按CTRL+D发送。若邮件接收成功则配置成功,若失败则有相关提示信息!

- 修改配置文件
vi /etc/netdata/health_alarm_notify.conf
- 把sendmail的参数指向msmtp
sendmail="/usr/bin/msmtp"
- 配置收件人信息 | 如下图
vi /etc/netdata/health_alarm_notify.conf
sendmail="/usr/bin/msmtp"

- 更改msmtprc的文件权限
chmod 600 ~/.msmtprc
如收到相关邮件则配置成功!
# enable debugging info on the console
export NETDATA_ALARM_NOTIFY_DEBUG=1
# send test alarms to sysadmin
/usr/libexec/netdata/plugins.d/alarm-notify.sh test
# send test alarms to any role
/usr/libexec/netdata/plugins.d/alarm-notify.sh test "ROLE"
如收到相关邮件则配置成功!
# enable debugging info on the console
export NETDATA_ALARM_NOTIFY_DEBUG=1
# send test alarms to sysadmin
/usr/libexec/netdata/plugins.d/alarm-notify.sh test
# send test alarms to any role
/usr/libexec/netdata/plugins.d/alarm-notify.sh test "ROLE"
经过一晚上的观察,发现邮件提醒虽然测试能够使用,但实际没法正常工作,后续找到了解决办法!具体原因不详,都弄一下吧!
-
-
以root身份进入docker
docker exec -it --user root <container id> /bin/bash
- 更改配置文件为644(官方教程为600,具体没测试)
chmod 644 ~/.msmtprc
- 复制配置文件
cp ~/.msmtprc /etc/msmtprc
经过一晚上的观察,发现邮件提醒虽然测试能够使用,但实际没法正常工作,后续找到了解决办法!具体原因不详,都弄一下吧!
以root身份进入docker
docker exec -it --user root <container id> /bin/bash
chmod 644 ~/.msmtprc
cp ~/.msmtprc /etc/msmtprc
