ubuntu mail的配置

下载:

Ubuntu 系统 heirloom-mailx 命令

安装heirloom-mailx

sudo apt-get install heirloom-mailx

CentOS安装mailx

 yum -y install mailx   #安装

 

问题:

1. hostname无效

          日志报错unable to qualify my own domain name (NOD2) -- using short name

2. 发送成功却没收到邮件

解决方法:

  • 针对hostname无效

修改/etc/hosts

通过hostname命令行修改hostname

  • 针对阿里云服务器25端口无效

使用465端口

1、qq 企业邮箱设置 smtps 465

首先,开启 smtp

登录qq企业邮箱 ——> 设置 ——> 客户端设置

接收服务器:imap.exmail.qq.com (使用SSL,端口号993)

发送服务器:smtp.exmail.qq.com (使用SSL,端口号465)

 

接着,配置 /etc/mail.rc,ubuntu配置 /etc/nail.rc或 /etc/s-nail.rc

注:仔细查看/etc目录下的文件,写错文件则会失败。

vim /etc/nail.rc

1

2

3

4

5

6

7

set from=robot@mimvp.com

set smtp=smtps://smtp.exmail.qq.com:465

set ssl-verify=ignore

set nss-config-dir=/root/.certs

set smtp-auth-user=robot@mimvp.com

set smtp-auth-password=mimvp-password

set smtp-auth=login

创建证书目录

mkdir -d /root/.certs

为保证certutil命令正常运行,需安装库

apt-get install libnss3-tools

然后,ssl 授权,执行如下命令

1

2

3

4

5

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

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

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

certutil -L -d .certs

certutil -A -n "GeoTrust SSL CA - G3" -t "Pu,Pu,Pu" -d ~/.certs/ -i ~/.certs/qq.crt

 

附:mail常见命令

清空所有邮件

# 方法一
echo > /var/spool/mail/root
# 方法二
mail
& d 1-53

发送邮件

echo  "hello word" | mail -s " title" 123456@qq.com  

参考链接

https://blog.mimvp.com/article/26918.html

https://blog.mimvp.com/article/26872.html

https://www.cnblogs.com/Cong0ks/p/13401772.html

https://blog.csdn.net/weixin_34326558/article/details/92258186

https://www.runoob.com/w3cnote/centos-mail-command-sendmail.html

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值