Linux 命令行发邮件sendmail,mailutils,mutt msmtp
2015-11-24 13:55
507 查看
本文环境:Ubuntu 14.04全新安装
【1.sendmail】 发邮件
【2.mailutils】 发邮件
【3.mutt msmtp】 发邮件
【1.sendmail】
【2.mailutils】
【1.sendmail】 发邮件
【2.mailutils】 发邮件
【3.mutt msmtp】 发邮件
【1.sendmail】
#sudo apt-get install sendmail 然后通过ps查看是否有sendmail进程,如果存在,则安装成功: #ps -ef|grep sendmail root 1282 1 0 13:39 ? 00:00:00 sendmail: MTA: accepting connections root@ubuntu:~# cat sendmail.sh #!/bin/bash /usr/sbin/sendmail -t << EOF From: Mail test Sender:chunli To: chunli@公司邮箱名字.cn Cc:chunli的朋友@公司邮箱名字.cn Subject: 树莓派 ---------------------------------- This is the mail content ... muhaha 树莓派发送邮件 --------------------------------- EOF 发送邮件: bash sendmail.sh
【2.mailutils】
利用mail工具发送,利用mail发送邮件必须安装mailutils sudo apt-get install mailutils root@ubuntu:~# mail -s "测试邮件" chunli@公司邮箱名字.cn < info.txt root@ubuntu:~# mail -s Title -t test1@163.com -t test2@163.com < hello.txt 如果要发送带附件的邮件,则需要先安装uuencode,uuencode 在sharutils包中 sudo apt-get install sharutils uuencode 附件名 显示附件名| mail -s 题目 目的邮箱 root@ubuntu:~# uuencode info.txt filename |mail -s Test chunli@公司邮箱名字.cn 如果按上面的方法,邮件只带一个附件,不显示正文,即将正文和附件组成联合文件发出。【3.mutt msmtp】
root@ubuntu:~# apt-get install mutt msmtp 配置,注意权限 root@ubuntu:~# vim /root/.muttrc set sendmail="/usr/bin/msmtp" set use_from=yes set realname="chunli的拼音" set from=chunli@公司邮箱名字.cn set envelope_from=yes root@ubuntu:~# vim /root/.msmtprc host 我用的真实信息 from 我用的真实信息 user 我用的真实信息 password 我用的真实信息 defaults port 587 tls on tls_trust_file /etc/ssl/certs/ca-certificates.crt account freemail host smtp.partner.outlook.cn from chunli@公司邮箱名字.cn auth on user chunli@公司邮箱名字.cn password 不加引号,真实密码 logfile ~/.msmtp.log account default : freemail 发邮件测试, 发送给多个人 邮件内容在mail.info root@ubuntu:~# echo "hello world" | mutt -s "title" chunli的朋友@abc.cn root@ubuntu:~# echo "test" |mutt -s "my_first_test" chunli@公司邮箱名字.cn wang_zhiliang@公司邮箱名字.cn root@ubuntu:~# cat mail.info |mutt -s "邮件主题" chunli@公司邮箱名字.cn msmtp发邮件,但是不显示正文 root@ubuntu:~# echo "test" |msmtp -t chunli@公司邮箱名字.cn
相关文章推荐
- sendmail和mailutils同时存在步骤
- 使用mailutils发邮件
- error LNK2019: 无法解析的外部符号_cvReleaseImage,该符号在函数_main 中被引用
- sgu 252 Railway Communication
- Error in Microsoft Visual Studio 2012 :No exports were found that match the constraint
- 解决Chrome、Safair、Webkit等内核浏览器默认文本域和文本
- [AlwaysOn Availability Groups]监控AG性能
- <学习笔记>安装apk报错:an error occured while deploying the file install failed older sdk
- 【leetcode】Container With Most Water
- 算法杂货铺——分类算法之朴素贝叶斯分类(Naive Bayesian classification)
- implicitlyWait和explicitlyWait的秘密
- 关于MediaRecorder(3761): start failed: -2147483648
- M2 Daily SCRUM要求
- UVa 11231 - Black and white painting
- LINK1123:failure during conversion to COFF:file invalid or corrupt解决办法
- 【AMPPZ2014】【BZOJ4152】The Captain
- AIDL实现及原理
- 用于 VMware vSphere ESXi 4/5/6 的HP智能阵列B140i SATA RAID控制器驱动程序
- 判别训练的多尺度可变形部件模型 A Discriminatively Trained, Multiscale, Deformable Part Model
- WAI-ARIA无障碍网页应用属性完全展示