linux邮箱命令行

学习教程

安装环境

1
2
3
4
5
6
7
# apt-get install sendmail
# systemctl start sendmail
# 
# 安装的时候 选择 network site
service postfix start
# 开机自动启动
chkconfig postfix on

配置 /etc/mail.rc

1
2
3
4
5
6
7
set from=lyr-2000@qq.com
set smtp=smtps://smtp.qq.com:465
set smtp-auth-user=lyr-2000@qq.com
set smtp-auth-password=q你的验证码
set smtp-auth=login
set ssl-verify=ignore
set nss-config-dir=/etc/pki/nssdb/

mail查看邮件

1
2
# 发送邮件
 echo "邮件正文aaa" |sudo mail -s "lllyr邮件主题6666"  lyr-2000@qq.com
1
mail

查看队列

1
2
mailq
# 查看发送的状态

生成证书

1
service postfix start
1
2
3
4
5
6
cd /etc/pki/nssdb
echo -n | openssl s_client -connect smtp.qq.com:465 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ./qq.crt
certutil -A -n "GeoTrust SSL CA" -t "C,," -d /etc/pki/nssdb/ -i /etc/pki/nssdb/qq.crt
certutil -A -n "GeoTrust Global CA" -t "C,," -d /etc/pki/nssdb/ -i /etc/pki/nssdb/qq.crt
certutil -L -d /etc/pki/nssdb/
certutil -A -n "GeoTrust SSL CA - G3" -t "Pu,Pu,Pu"  -d ./ -i qq.crt

遇到的问题

解决成功的博客

参考

1
2
3
mailx 无法在 qq邮箱中查看  cannot send message: Process exited with a non-zero status

postfix/postfix-script: fatal: the Postfix mail system is not running

参考的博客文章

1
2
postfix start
echo "邮件正文" | mail -s "邮件主题" lyr-2000@qq.com