• 欢迎访问显哥博客,本网站纯属学习技术,绝无商业用途,欢迎小伙伴们共同学习!研究技术!QQ:52249909 加我QQ
  • 世界75亿人,这么小的概率,能认识你,是我一生的幸运,不妨加个QQ接触一下:52249909 加我QQ

Ubuntu系统安装mailx邮件服务heirloom-mailx发送email【显哥出品,必为精品】

技术栈 lixian 4年前 (2020-09-29) 21064次浏览 1个评论 扫描二维码

1.安装heirloom-mailx服务(注意是Ubuntu系统,Linux系统直接yum装mailx就行了)

#1.添加heirloom-mailx apt源(在文件最下方添加一行)
[root@test.lixian.fun ~]# cat /etc/apt/sources.list
deb http://cz.archive.ubuntu.com/ubuntu xenial main universe

#2.更新apt
[root@test.lixian.fun ~]# apt update

#3.安装heirloom-mailx
[root@test.lixian.fun ~]# apt install heirloom-mailx -y

2.配置邮箱信息(三个邮箱选择一个就行了)

[root@test.lixian.fun ~]# vim /etc/s-nail.rc
###for 163邮箱
set from="xxxxx@163.com" #发件地址
set smtp="smtps://smtp.163.com:465" #smtp服务器
set smtp-auth-user="xxxxxx@163.com" #登录发件地址
set smtp-auth-password="xxxx" #授权码
set smtp-auth=login #登录方式,默认是login,也可以改成CRAM-MD5或PLAIN方式


###for outlook
set from="xxxx@outlook.com"
set smtp="outlook.office365.com:587"
set smtp-auth-user="xxxx@outlook.com"
set smtp-auth-password="xxxx" #明文密码
set smtp-use-starttls #加密方式
set ssl-verify=ignore # 忽略ssl认证
set smtp-auth=login

###for QQ mail
set from="xxx@qq.com"
set smtp="smtps://smtp.qq.com:465"
set smtp-auth-user="xxx@qq.com"
set smtp-auth-password="ahkphxxabcbshabbga" #QQ邮箱授权码
set smtp-auth=login

3.发送邮件命令

echo "内容"|s-nail -s "主题" xxxx@163.com,xxxx@outlook.com #多个邮箱用逗号隔开
#或者:
s-nail -s "邮件主题" xxx@163.com < result.txt

ps:加参数v可以看到mail输出的详细信息
s-nail -vs "邮件主题" xxx@163.com < result.txt

#发送带附件邮件
s-nail -a 附件 -s "主题" 收件地址 < 文件(邮件正文.txt)
s-nail -a /xxx.tar.gz -s "主题" xxx@163.com < ./xxx.txt

#shell 当编辑器,编辑完内容后按Ctrl-D结束
s-nail -s '主题‘ xxx@163.com

本站博主 , 版权所有丨如未注明 , 均为原创
转载请注明原文链接:Ubuntu系统安装mailx邮件服务heirloom-mailx发送email【显哥出品,必为精品】
喜欢 (0)

您必须 登录 才能发表评论!

(1)个小伙伴在吐槽
  1. I may need your help. I tried many ways but couldn't solve it, but after reading your article, I think you have a way to help me. I'm looking forward for your reply. Thanks.
    gateio2023-06-03 07:03