使用Msmtp mutt shell发邮件

1、编译一下软件

软件下载地址:http://sourceforge.net/projects/msmtp/files/msmtp/1.4.13/msmtp-1.4.13.tar.bz2/download

tar jxvf msmtp-1.4.13.tar.bz2

./configure --prefix=/opt/msmtp

make

make install

2、查看配置文件在那儿

[root@server bin]# ./msmtp --version

msmtp version 1.4.13

TLS/SSL library: none

Authentication library: built-in

Supported authentication methods:

plain cram-md5 external login

IDN support: disabled

NLS: enabled, LOCALEDIR is /opt/msmtop/share/locale

System configuration file name: /opt/msmtp/etc/msmtprc -----需要手动建立

User configuration file name: /root/.msmtprc

Copyright (C) 2007 Martin Lambers and others.

This is free software. You may redistribute copies of it under the terms of

the GNU General Public License .

There is NO WARRANTY, to the extent permitted by law.

3、配置一下msmtp的配置文件

[root@server ]#mkdir -p /opt/msmtp/{etc,log}

[root@server ]#cd /opt/msmtp/etc

[root@server etc]# vi msmtprc (增加以下内容)

# Set default values for all following accounts.

defaults

logfile /opt/msmtp/log/msmtp.log

# The SMTP server of the provider.

account sohu

host smtp.sohu.com

from [email protected]

auth login

user your_account

password your_password

# Set a default account

account default : sohu

保存退出,并对这个文件加上可执行权限:chmod +x msmtprc

到这儿时,最好先测试一下

/opt/msmtp/bin/msmtp [email protected]

hello,test

ctrl +d

tail -f /opt/msmtp/log/msmtp.log 看看有没有成功。

然后再进入到上面的邮件中,看看信收到没有

4、配置mutt

下载并安装mutt安装包:  mutt-1.5.11.tar.gz

tar -xzvf mutt-1.5.11.tar.gz

./configure --prefix=/opt/mutt &&make &&make install

[root@server bin]# vi /etc/Muttrc (增加以下内容)

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

set realname="actor"

set use_from=yes

set editor="vi"

5、现在都已经搞定了,开始测试看看

[root@server bin]# echo "测试一下" | mutt -s "messages" [email protected]

你可能感兴趣的:(shell,邮件,Mutt,msmtp,休闲)