RHCE---使用邮箱客户端s-nail

使用邮箱客户端s-nail

方案一:使用网易邮箱

1,挂载虚拟镜像

[root@localhost ~]# mount  /dev/sr1 /mnt
mount: /mnt: /dev/sr1 already mounted on /run/media/root/RHEL-9-3-0-BaseOS-x86_64.

2,编辑环境文件

[root@localhost ~]# vim /etc/yum.repos.d/base.repo
[root@localhost ~]# cat /etc/yum.repos.d/base.repo 
    [BaseOS]
    name=BaseOS
    baseurl=file:///mnt/BaseOS
    gpgcheck=0

    [AppStream]
    name=AppStream
    baseurl=file:///mnt/AppStream
    gpgcheck=0

3,安装s-nail邮箱客户端

[root@localhost ~]# dnf install s-nail -y
Complete!

4,编写邮箱客户端的环境

[root@localhost ~]# vim /etc/s-nail.rc
[root@localhost ~]# tail -5 /etc/s-nail.rc
set from=XXXXXXXXXXXXXXXXX@163.com         ------粘贴自己的网易邮箱账号(没有账号可注册)
set smtp=smtp.163.com
set smtp-auth-user=XXXXXXXXXXXXXXXXX@163.com       ---这里也是自己的网易邮箱账号
set smtp-auth-password=XXXXXXXXXXXXX(授权码)     ------这里需要获取授权码
set smtp-auth=login

授权码获取方式:

在这里插入图片描述

得到授权码后,粘贴进文件内部即可使用。注意在退出文件编辑时需要使用强制保存退出(wq!命令),否则配置文件的命令不会生效。

5,验证邮箱

[root@localhost ~]# echo 你好世界 | mail -s jinggao XXXXXXXXXXXXX@163.com      ------网易邮箱账号
s-nail: Warning: variable superseded or obsoleted: smtp
s-nail: Warning: variable superseded or obsoleted: smtp-auth-user
s-nail: Warning: variable superseded or obsoleted: smtp-auth-password
s-nail: Obsoletion warning: please do not use *smtp*, instead assign a smtp:// URL to *mta*!
s-nail: Obsoletion warning: Use of old-style credentials, which will vanish in v15!
s-nail:   Please read the manual section "On URL syntax and credential lookup"

登录网易邮箱即可看见邮件,表明验证成功。

在这里插入图片描述

方案二:使用QQ邮箱

1,挂载虚拟镜像

[root@localhost ~]# mount  /dev/sr1 /mnt
mount: /mnt: /dev/sr1 already mounted on /run/media/root/RHEL-9-3-0-BaseOS-x86_64.

2,编辑环境文件

[root@localhost ~]# vim /etc/yum.repos.d/base.repo
[root@localhost ~]# cat /etc/yum.repos.d/base.repo 
    [BaseOS]
    name=BaseOS
    baseurl=file:///mnt/BaseOS
    gpgcheck=0

    [AppStream]
    name=AppStream
    baseurl=file:///mnt/AppStream
    gpgcheck=0

3,安装s-nail邮箱客户端

[root@localhost ~]# dnf install s-nail -y
Complete!

4,s-nail程序登录验证qq账号

[root@localhost ~]# vim /etc/s-nail.rc
[root@localhost ~]# tail -7 /etc/s-nail.rc
set from=XXXXXXXXXX@qq.com             ------QQ邮箱账号
set smtp=smtps://smtp.qq.com:465
set smtp-auth-user=XXXXXXXXXX@qq.com          -----QQ邮箱账号
set smtp-auth-password=XXXXXXXXXXXX           -----QQ授权码
set smtp-auth=login
set ssl-verify=ignore
set nss-config-dir=/root/.certs

在qq客户端程序(如浏览器中进入邮箱登录QQ邮箱->设置->账户)中通过设置开启imap/smtp服务提供第三方程序账号的授权码:

在这里插入图片描述

5,因为需要 QQ 邮箱的 SSL 证书,所以我们还需要手动的获取QQ 邮箱的证书保存到本地指定的目录里以备调用和验证,具体命令如下:

[root@localhost ~]# mkdir -p /root/.certs/
[root@localhost ~]# echo -n | openssl s_client -connect smtp.qq.com:465 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ~/.certs/qq.crt
[root@localhost ~]# certutil -A -n "GeoTrust SSL CA" -t "C,," -d ~/.certs -i ~/.certs/qq.crt
[root@localhost ~]# certutil -A -n "GeoTrust Global CA" -t "C,," -d ~/.certs -i ~/.certs/qq.crt
[root@localhost ~]# certutil -L -d /root/.certs

为了防止出现前文所说的发送邮件警告提示,还需要进入邮箱 SSL 证书存放目录 /root/.certs 里执行如下命令:

[root@localhost ~]# cd /root/.certs
[root@localhost ~]# 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.

6,验证测试

[root@localhost .certs]# echo 123 | mail -s test XXXXXXXXXX@qq.com        -----QQ邮箱账号
s-nail: Warning: variable superseded or obsoleted: smtp
s-nail: Warning: variable superseded or obsoleted: smtp-auth-user
s-nail: Warning: variable superseded or obsoleted: smtp-auth-password
s-nail: Warning: variable superseded or obsoleted: ssl-verify
s-nail: Obsoletion warning: please do not use *smtp*, instead assign a smtp:// URL to *mta*!
s-nail: Obsoletion warning: Use of old-style credentials, which will vanish in v15!
s-nail:   Please read the manual section "On URL syntax and credential lookup"
s-nail: SMTP server: /root/dead.letter 10/220
s-nail: ... message not sent

登录QQ邮箱即可看见邮件,表明验证成功。

在这里插入图片描述

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值