---
title: "使用Msmtp mutt shell发邮件 （转）"
author: "a3mao"
date: "2010-11-26T09:32:07Z"
tags: []
categories: ["编程语言"]
slug: "msmtp-mutt-shell"
draft: false
lastmod: "2010-11-26T09:32:07Z"
id: 825147
url: "https://a3mao.iteye.com/blog/825147"
---

原文地址：http://fdsazi.blog.51cto.com/1871366/421479

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、查看配置文件在那儿

# ./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的配置文件

#mkdir -p /opt/msmtp/{etc,log}

#cd /opt/msmtp/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 your_account@sohu.com

auth login

user your_account

password your_password

# Set a default account

account default : sohu

保存退出，并对这个文件加上可执行权限:chmod +x msmtprc

到这儿时，最好先测试一下

/opt/msmtp/bin/msmtp test@gmail.com

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

# vi /etc/Muttrc (增加以下内容）

set sendmail="/opt/msmtp/bin/msmtp"

set realname="actor"

set use_from=yes

set editor="vi"

5、现在都已经搞定了，开始测试看看

# echo "测试一下" | mutt -s "messages" test@gmail.com


根据此文章试过了，可以发信，不过在安装mutt的时候是用 sudo apt-get install mutt来的，并非文章中提到的安装。