Linux 中配置mailx 用来发邮件

本来配置mai是很简单的操作,但是由于阿里云禁用了25号端口,所以只能使用465端口用来发送监控邮件。这个配置稍微复杂一点。

一.安装mail

centos: yum install mail

ubuntu:apt install mail

二.修改配置文件

vim /etc/mail.rc


三.参数解释

 from==>发送邮箱

 smtp-auth-user==>发送邮箱

 smtp==>发送邮箱的smtp服务器 126邮箱的smtp服务器为smtps://smtp.126.com:465

smtp-auth-password=>口令   //注意不是密码 这里需有在网页上登陆邮箱找到设置口令的地方开启 默认是关闭的

nss-config-dir==>/root/.certs 存放证书的目录

四.如何配置证书

mkdir -p /root/.certs/

echo -n | openssl s_client -connect smtp.126.com:465| sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ~/.certs/126.crt

certutil -A -n "GeoTrust Global CA" -t "C,," -d ~/.certs -i ~/.certs/126.crt

certutil -L -d /root/.certs

若需要qq的ssl只需把第二条命令中的smtp.xxx.com:465给替换了就行

五.测试

echo Hello World | mailx -s test [email protected]

你可能感兴趣的:(Linux 中配置mailx 用来发邮件)