打开qq邮箱网页版>>设置>>帐户>>开启IMAP/SMTP服务
生成授权码后文的密码都是指这个授权码
修改/etc/mail.rc sudo vim /etc/mail.rc在后面添加如下内容
set from="username@qq.com" set smtp-auth=login set mta=smtps://username:password@smtp.qq.com:465 #smtp服务器端口是464 set v15-compat #必须要password 是生成的授权码
测试 echo "this is test" | mail -s "test email" username@qq.comSMTP是一个“推”的协议,它不允许根据需要从远程服务器上“拉”来消息。要做到这点,邮件客户端必须使用POP3或IMAP。另一个SMTP服务器可以使用ETRN在SMTP上触发一个发送。
SMTP只能发,不能接收邮件,所以我们要借助IMAP来接收邮件.
修改/etc/mail.rc在文件后添加如下内容
set imap-keepalive=240 set imap-cache=~/.imap_cache set inbox="imaps://username:password@imap.qq.com:993" #993是imap服务器端口这里的password也是授权码
直接运行mail命令的效果
[zcy@archlinux ~]$ mail mail version v14.9.19. Type `?' for help imaps://287****712@imap.qq.com:993/INBOX: 18 messages 11 unread O 1 GitHub 2020-08-08 09:26 936/80293 GitHub Explore today Aug 8 O 2 GitHub 2020-08-09 09:26 935/81544 GitHub Explore today Aug 9 O 3 Microsoft ???????? 2020-08-10 09:04 151/10590 Microsoft ???????????? O 4 GitHub 2020-08-10 09:26 932/80918 GitHub Explore today Aug 10 O 5 GitHub 2020-08-11 09:36 932/81524 GitHub Explore today Aug 11 >U 6 GitHub 2020-08-12 09:26 /81724 GitHub Explore today Aug 12 U 7 GitHub 2020-08-13 09:26 /76443 GitHub Explore today Aug 13mail U 8 GitHub 2020-08-14 09:26 /81201 GitHub Explore today Aug 14 O 9 GitHub 2020-08-15 09:26 /81723 GitHub Explore today Aug 15 U 10 GitHub 2020-08-16 09:26 /81993 GitHub Explore today Aug 16 U 11 newsletter@newslet 2020-08-17 09:12 /9768 ??????????????????????????? U 12 GitHub 2020-08-17 09:26 /82270 GitHub Explore today Aug 17 U 13 GitHub 2020-08-18 09:36 /82078 GitHub Explore today Aug 18 O 14 GitHub 2020-08-19 09:26 /83414 GitHub Explore today Aug 19 U 15 GitHub 2020-08-20 09:26 /77469 GitHub Explore today Aug 20 U 16 GitHub 2020-08-21 09:26 /84174 GitHub Explore today Aug 21参考:
Archlinux s-nail