ITPub博客

首页 > 应用开发 > IT综合 > 利用msmtp+mutt 发送mail

利用msmtp+mutt 发送mail

原创 IT综合 作者:tolilong 时间:2013-10-24 10:23:26 0 删除 编辑
利用msmtp+mutt 发送mail[@more@]

首先下载msmtp-1.4.27.tar.zip压缩包

[root@primary opt]# unzip msmtp-1.4.27.tar.zip

[root@primary opt]# tar -xvf msmtp-1.4.27.tar.bz2

[root@primary opt]# cd msmtp-1.4.27

[root@primary msmtp-1.4.27]# ./configure --prefix=/opt/msmtp --with-ssl=openssl

[root@primary msmtp-1.4.27]# make

[root@primary msmtp-1.4.27]# make install

[root@primary msmtp-1.4.27]# cd ..
[root@primary opt]# ll
total 620
drwxr-xr-x 4 root root 4096 Oct 22 13:53 msmtp
drwxr-xr-x 8 1000 1000 4096 Oct 22 13:53 msmtp-1.4.27
-rw-r--r-- 1 root root 301918 Jan 11 2012 msmtp-1.4.27.tar.bz2
-rw-r--r-- 1 root root 305640 Oct 22 13:48 msmtp-1.4.27.tar.zip
drwxr-xr-x 3 root root 4096 Sep 10 17:27 ORCLfmap

[root@primary opt]# cd msmtp

[root@primary msmtp]# mkdir etc

[root@primary msmtp]# cd etc/
[root@primary etc]# ll
total 0
[root@primary etc]# vi msmtprc

#加入如下内容

account default
host smtp.xxxxx.com
port 25
from li.long@xxxx.com
auth login
tls off
user li.long@xxxxx.com
password xxxxxxx

logfile /var/log/mmlog

[root@primary bin]# /opt/msmtp/bin/msmtp li.long@xxxx.com

之后便可以收到邮件了。

.mailrc中加入 set sendmail="/opt/msmtp/bin/msmtp"

[root@primary ~]# vi .mailrc

set sendmail="/opt/msmtp/bin/msmtp"

即可使用:

[root@primary ~]# echo "this is a test mail" | mail -s "TEST mail" li.long@xxxxx.com

发送邮件了。

==============================================================================

但是利用这种方法,有时候收不到邮件,也找不到什么原因。

在/etc/Muttrc中添加相关内容后,可以解决相关问题。(删掉/root/.mailrc文件)

这个需要mutt 包。

[root@primary ~]# vi /etc/Muttrc

set from="li.long@xxxx.com"
set sendmail="/opt/msmtp/bin/msmtp"
set use_from=yes
set realname="database primary" --显示发件人。
set editor="vi"

[root@primary ~]# mutt -s "this message from primary database " li.long@xxxxx.com < /opt/msmtp/etc/msmtprc

即可发送/opt/msmtp/etc/msmtprc文件中的内容了。

[root@primary ~]# echo "test" |mutt -s "test" li.long@xxxxx.com

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/24237320/viewspace-1060988/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2010-07-13

  • 博文量
    406
  • 访问量
    1208671