#启动邮箱服务
systemctl start postfix.service
#配置用户的邮箱发送邮件
vim /etc/mail.rc
set from="xxx@xxx.com"
set smtp="smtps://smtp.exmail.qq.com:465"
set smtp-auth-user="xxx@xxx.com"
set smtp-auth-password="xxxxxx"
set smtp-auth=login
set ssl-verify=ignore
set nss-config-dir=/etc/pki/nssdb
#测试发送邮件
[root@VM_centos ~]# echo "messages" | mail -v -s "subject" yxxx@qq.com
Resolving host smtp.exmail.qq.com . . . done.
Connecting to 163.177.90.125:465 . . . connected.
Error in certificate: Peer's certificate issuer is not recognized.
Comparing DNS name: "pop.qq.com"
Comparing DNS name: "ex.qq.com"
Comparing DNS name: "imap.exmail.qq.com"
Comparing DNS name: "rtx.exmail.qq.com"
Comparing DNS name: "smtp.exmail.qq.com"
SSL parameters: cipher=AES-128, keysize=128, secretkeysize=128,
issuer=CN=GeoTrust RSA CA 2018,OU=www.digicert.com,O=DigiCert Inc,C=US
subject=CN=pop.qq.com,OU=R&D,O=Shenzhen Tencent Computer Systems Company Limited,L=Shenzhen,ST=Gu
220 smtp.qq.com Esmtp QQ Mail Server
...
>>> QUIT
221 Bye
#解决证书解析报错
#手动的获取QQ 邮箱的证书保存到本地指定的目录里以备调用和验证
[root@VM_centos ~]# cd /etc/pki/nssdb/
[root@VM_centos nssdb]# ls
cert8.db cert9.db key3.db key4.db pkcs11.txt secmod.db
[root@VM_centos nssdb]# echo -n | openssl s_client -connect smtp.exmail.qq.com:465 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' >qq.crt
depth=2 C = US, O = DigiCert Inc, OU = www.digicert.com, CN = DigiCert Global Root CA
verify return:1
depth=1 C = US, O = DigiCert Inc, OU = www.digicert.com, CN = GeoTrust RSA CA 2018
verify return:1
depth=0 C = CN, ST = Guangdong, L = Shenzhen, O = Shenzhen Tencent Computer Systems Company Limited, OU = R&D, CN = pop.qq.com
verify return:1
DONE
[root@VM_centos nssdb]# certutil -A -n "GeoTrust SSL CA" -t "C,," -d /etc/pki/nssdb -i qq.crt
[root@VM_centos nssdb]# certutil -A -n "GeoTrust Global CA" -t "C,," -d /etc/pki/nssdb -i qq.crt
[root@VM_centos nssdb]# certutil -L -d /etc/pki/nssdb
#进入邮箱 SSL 证书存放目录,为了信任证书的标记操作
[root@VM_centos nssdb]# certutil -A -n "GeoTrust SSL CA - G3" -t "Pu,Pu,Pu" -d ./ -i qq.crt
Notice: Trust flag u is set automatically if the private key is present.
#解决发送是附件
#只要把行尾^M去掉,然后发送的话就不会是附件的形式了
[root@VM_centos nssdb]# yum -y install dos2unix.x86_64
[root@VM_centos nssdb]# vim /usr/lib/zabbix/alertscripts/sendmail.sh
#!/bin/bash
TMP_FILE=/usr/lib/zabbix/alertscripts/tmp_messages.txt
echo $3 | tr '\r\n' '\n' > ${TMP_FILE} #把^M替换为\n
# dos2unix ${TMP_FILE} #解决发送的邮件内容变成附件的问题 未解决
subject=$2
mail -s "${subject}" $1 >>/var/log/sendmail.log 2>&1 <${TMP_FILE}
#注意权限是chown zabbix.zabbix
#zabbix 管理---->报警媒介类型
#查看zabbix脚本位置
[root@VM_centos alertscripts]# grep alertscripts /etc/zabbix/zabbix_server.conf
AlertScriptsPath=/usr/lib/zabbix/alertscripts


- zabbix4.2配置邮件+脚本报警:以QQ邮箱为例
一.邮箱配置:开启smtp服务和授权 开启smtp选项后,系统会生成一个授权,你需要记住这个授权码,后面需要写入配置文件. 二.配置管理mailx: (1)安装mailx:[root@zabbix-s ...
- zabbix配置报警媒介-用户-动作-邮件脚本触发mailx邮件报警
2018-09-16更新,新版本zabbix不需要使用脚本发送邮件,在zabbix web界面直接配置就可以 配置邮件参数,测试发送邮件 确认安装相关服务,centos7默认安装 [root@VM_1 ...
- 通过脚本发送zabbix邮件报警
zabbix原生的报警媒介类型中,邮件报警是我们常用的方式.当我们在CentOS6上面安装zabbix3.0并配置邮件报警的时候,在邮件配置正确的前提下,不管触发器如何触发,邮件总是发送不出去,但是在 ...
- centos7之zabbix邮件报警(短信报警)
前言 前面我们介绍了zabbix的基本linux和window及SNMP流量的简单监控,我们知道作为运维人员,需要7x24小时待命,但是我们不可能时时刻刻都坐在电脑旁边查看监控上的各个主机状态,所以我 ...
- Zabbix邮件报警配置
一.安装sendmail或者postfix yum install sendmail #安装 service sendmail start #启动 chkconfig sendmail on #设置开 ...
- zabbix 邮件报警
一.设置sendmail 安装sendmail yum install -y sendmail systemctl start sendmail.service 配置 cd /usr/lib/zab ...
- Zabbix 邮件报警示例
Zabbix 邮件报警示例: 1.编辑 mail.rc 文件添加默认的邮箱配置 # vi /etc/mail.rc set from=1234567@qq.com set smtp=smtp.qq. ...
- zabbix*邮件报警 *用户参数User parameters *定义key值 *Agentd主动模式与被动模式
邮件报警 #下载安装邮件报警系统wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz yum - ...
- zabbix 邮件报警(五)
一.sendEmail配置zabbix邮件报警 1.下载sendEmail: wget http://caspian.dotconf.net/menu/Software/SendEmail/sendE ...
随机推荐
- HTML的列表标签和表格标签
网页的列表和表格 列表的分类 无序列表 有序列表 自定义列表 有序列表 <!--有序列表--><ol> <li>辽宁</li> <li ...
- 调用原生硬件 Api 实现照相机 拍照和相册选择 以及拍照上传
一.Flutter image_picker 实现相机拍照和相册选择 https://pub.dev/packages/image_picker 二.Flutter 上传图片到服务器 ht ...
- windows 下安装memcache拓展
Windows下安装memcached (linux 接下来会继续 学习) 以管理员身份进入CMD 模式,具体方法:C:/windows/system32 管理员身份打开cmd.exe memcach ...
- RHEL7忘记密码:修改root密码
博客链接:http://blog.csdn.net/derkampf/article/details/54346516 问题描述:日常工作和使用红帽子7系统时,容易发生忘记密码(root)这种尴尬的情 ...
- IDEA配置pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...
- 十大常见web漏洞及防范
十大常见web漏洞 一.SQL注入漏洞 SQL注入攻击(SQL Injection),简称注入攻击.SQL注入,被广泛用于非法获取网站控制权,是发生在应用程序的数据库层上的安全漏洞.在设计程序,忽略了 ...
- linux 网卡限速
#安装git yum -y install git #下载wondershaper git clone https://github.com/magnific0/wondershaper.git 第 ...
- Wx-小程序-使用canvas截图保存
1. wxml 页面 使用画布来站位,并给按钮添加绑定事件 <button class='btn btn-theme' bindtap='setSaveImage'>保存图片到本地< ...
- github,gitlab的区别
链接:https://blog.csdn.net/Xiamen_XiaoHong/article/details/83655447 总而言之:gitlab最优
- React的React.createRef()/forwardRef()源码解析(三)
1.refs三种使用用法 1.字符串 1.1 dom节点上使用 获取真实的dom节点 //使用步骤: 1. <input ref="stringRef" /> 2. t ...