[TOC]
1. email 邮件命令
CentOS/RHEL安装命令:1
yum -y install mailx
mail 配置:
vim /etc/mail.rc1
2
3
4
5
6
7
8
9
10
11
12
13#配置参数
from: 对方收到邮件时显示的发件人
smtp: 指定第三方发送邮件的smtp服务器地址
smtp-auth: SMTP的认证方式。默认是LOGIN,也可改为CRAM-MD5或PLAIN方式
smtp-auth-user: 第三方发邮件的用户名
smtp-auth-password: 用户名对应密码
#配置详情
set from="12123@qq.com"
set smtp="smtp.qq.com"
set smtp-auth-user="12123@qq.com"
set smtp-auth-password="aawbubhyfhuucbdd"
set smtp-auth=login
mail 命令:
mail –h
-s <邮件主题>:指定邮件的主题;
-c <地址>:添加邮件抄送人,多个人时用逗号隔开;
-b <地址>:添加邮件暗送人;
-a <附件>: 添加附件。
注:部分系统参数稍有差异,最好看帮助
1 | # 语法: |

WeiyiGeek.测试发信
脚本:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
help(){
echo "eg: $0 [Subject] [address] [content_file] [file]"
echo ""
exit 1
}
if [ ! -n "$1" ] ; then
help
fi
cDate=`date +%Y%m%d`
if [ ! -n "$2" ] ; then
help
else
mail_to=$2
echo " Send Mail to ${mail_to}"
fi
if [ ! -n "$4" ] ; then
mail -s $1 ${mail_to}<$3
else
mail -s $1 -a $4 ${mail_to}<$3
fi
[root@123]$ ./sendmail.sh test xxxx@qq.com abc.txt
Send Mail to xxx@qq.com
F&Q
邮件服务启动:1
systemctl status postfix
问题1:sendmail重启报libmysqlclient.so.18不存在
问题描述:1
2sendmail restart
sendmail: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory
问题原因:1
2
3
4
5
6[root@node2 ld.so.conf.d]# ldd /usr/sbin/sendmail
linux-vdso.so.1 => (0x00007ffce43fa000)
libldap-2.4.so.2 => /lib64/libldap-2.4.so.2 (0x00007f97fc570000)
liblber-2.4.so.2 => /lib64/liblber-2.4.so.2 (0x00007f97fc361000)
libpcre.so.1 => /lib64/libpcre.so.1 (0x00007f97fc0ff000)
libmysqlclient.so.18 => not found #发现缺少该库
问题解决:1
2
3
4#下载该动态链接库和重新刷新加载lib
sudo wget -O /usr/lib/libmysqlclient.so.18 http://files.directadmin.com/services/es_7.0_64/libmysqlclient.so.18
#echo "/usr/lib/" >>/etc/ld.so.conf
ldconfig