ubuntu下使用mutt和msmtp发送邮件的简单配置

sudo apt-get install mutt

 

sudo apt-get install msmtp

安装好了这两个包之后,就是进行相关配置文件的配置了:

 

首先配置 mutt,系统全局设置配置文件在 /etc/Muttrc,如果使用某个系统用户,可以在~/.muttc中设置,没有该文件,就自己创建。

vi .muttrc

1     set sendmail = " /usr/bin/msmtp "
2     set use_from = yes
3     set realname = " zhxia "
4     set from = zhenghon @ ajk.com
5     set envelope_from = yes

 

 

接着,配置msmtp

 

创建 ~/.msmtprc 和 ~/.msmtp.log,分别为配置文件和日志文件

vi .msmtprc

1  account  default
2  host smtp.corpease.net
3  from zhenghong @ ajk.com
4  auth plain
5  user zhenghong @ ajk.com
6  password xxxxxxx
7  logfile ~ / .msmtp.log

 

由于password是明文,所以需要修改此文件的访问权限

chmod 600 .msmtprc 

同时创建 日志文件 touch ~/.msmtp.log

 

做完了以上的配置之后,可以进行邮件的发送测试了:

 

查看SMTP服务器是否支持认证的TLS加密:

 

1  zhxia @ zhxia - Desktop:~ $  msmtp  -- host = smtp.corpease.net  -- serverinfo
2  SMTP server at smtp.corpease.net (mail3.corpease.net [ 61.145 . 121.45 ]), port  25 :
3      corpease.net Anti - spam GT  for  Coremail System (corpease[ 20100527 ])
4  Capabilities:
5      PIPELINING:
6          Support  for  command grouping  for  faster transmission
7      AUTH:
8          Supported authentication methods:
9          PLAIN LOGIN

 

 发送邮件测试:

1  echo  " hello world "   |  mutt  - " title "   252578390 @ qq.com

 一般情况下,均可已正常接收邮件。

 下面是一个比较完整的发送邮件示例:

 

1  echo  " hello "   |  mutt  - " title "   252578390 @ qq.com,zhenghong00 @ 163 .com  - 40271871 @ qq.com  - / tmp / ip.tmp

 发送给多人,抄送,添加附件

 

address = " zhenghong@ajk.com "
echo 
$content | mutt   - " ${subject} "   - e 'set content_type = " text/html " - e 'send - hook .  " my_hdr  X-Priority: 1 " $address

 发送邮件时设置邮件的文本类型为:html格式,邮件的等级为:重要

参考文章:

 http://hi.baidu.com/realasking/blog/item/10c1c3d346be6cd2a9ec9adc.html

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值