LinuxSir.Org  
| 网站首页 | 注册账号 | 论坛帮助 |

欢迎来到LinuxSir.Org!
您还未登录,请登录后查看论坛,或者点击论坛上方的注册链接注册新账号。


发表新主题 回复
 
主题工具
旧 05-09-13, 15:26 第 1 帖
jamescsy
 
 
 
注册会员  
  注册日期: May 2005
  帖子: 102
  精华: 0
 

标题: [指南]Exim4+fetchmail+mutt在debian下收发电子邮件


Debian下默认装的是exim4,而且也说的很清楚,唯一可以取代exim的是postfix,不推荐使用sendmail和qmail。所以,还是配置默认的exim4来的好一些。下面是我的配置过程,希望对大家能有所帮助!

#本指南指导Debian环境下,用Exim4 + fetchmail + mutt来收发电子邮件。
#需要安装的软件为:exim4, fetchmail, mutt, antiword(word转换为txt的工具)等
#假设已经apt-get安装好以上文件
本指南主要有三个步骤:
1、设置exim4,通过smarthost外发邮件;
2、设置fetchmail,接受pop邮件;
3、设置mutt,处理邮件(阅读、书写)。

首先,设置exim4:(以tom.com邮箱举例)
dpkg-reconfigure exim4-config
(1)将配置文档拆分成小文件么? 否
(2)选择“用smarthost发信;通过smtp或fetchmail接受邮件”
(3)系统邮件名称,随意;(这里我写了tom.com)
(4)要监听的入站 SMTP 连接的 IP 地址:127.0.0.1 (这样,就只有本机可以利用exim4)
(5)其它可接受的邮件目的地址:(empty)
(6)为这些主机进行邮件转发:(empty)
(7)负责处理从本机寄出的邮件的机器(smarthost):真正用来外发邮件的smtp地址
(我这里用smtp.tom.com)
(8)要在寄出的邮件中隐藏本地邮件名称吗? 是
(9)本地用户的可视域名:同(3)
(10)保持最小 DNS 查询量吗(按需拔号 Dial-on-Demand)? 否
还要修改几个配置文件:
(1)/etc/exim4/passwd.client,smtp的帐号密码设置
加入:tomsmtp.163.net:邮箱帐号:邮箱密码(这里之所以是tomsmtp.163.net,而非smtp.tom.com,是因为ping smtp.tom.com时候,会显示tomsmtp.163.net。你不是tom.com的邮箱的话,请换成您自己的smtp服务器地址)
(2)/etc/email-addresses,系统邮箱地址
加入:user: someone@isp.com,比如,我linux...mescsy@tom.com
(3)/etc/exim4/exim4.conf.template,exim4配置文件
在最后加入一行:AUTH_CLIENT_ALLOW_NOTLS_PASSWORDS=1(意思是smtp的帐号密码以明文传输,因为目前大多数smtp服务器不支持tls,所以,加入这一行才能认证通过,这是关键,很多exim配置中都没提到)
(4)~/.muttrc,mutt配置文件
这里加入:
set envelope_from=yes
set sendmail="/usr/sbin/exim4"
set from=jamescsy@tom.com(根据你自己的邮箱,跟smtp服务器对应的帐号填写)
set realname="jameswang"
set use_from=yes
这样exim4算是设置好了,你可以通过mutt发邮件了。(当然,你可能需要dpkg-reconfigure exim4-config来重启一下mta,配置文件才能生效)

其次:配置fetchmail。
这个比较简单,修改~/.fetchmail文件,加入:
# Configuration created Mon Aug 29 16:08:29 2005 by fetchmailconf
set postmaster "jameswang"(改为你自己使用的linux用户名)
set bouncemail
set no spambounce
set properties ""
poll pop.zj.com
protocol POP3
user "jamescsy"
password "mypasswd"
poll pop.sina.com
protocol POP3
...
以后,在终端下输入fetchmail,就会把各个邮箱的邮件下载到/var/spool/mail/下

最后,配置mutt
(其实,刚才的~/.muttrc已经配置的差不多了,到现在位置,就已经可以通过mutt收发邮件了。)

为了和word附件的配合,需要在.muttrc中加入:
auto_view application/msword
另外,还需要在~/.mailcap中加入:
text/html; lynx -force_html %s; needsterminal;
application/msword; /usr/bin/antiword '%s'; copiousoutput; #这里用到antiword,apt-get install就行
description="Microsoft Word Text"; nametemplate=%s.doc
这样,就能够在mutt中显示word附件了。

ok
  jamescsy 当前离线   回复时引用此帖
旧 05-09-13, 15:42 第 2 帖
blithe
 
blithe 的头像
 
 
注册会员  
  注册日期: Feb 2004
  我的住址: sjtu
  帖子: 284
  精华: 1
 



这些天刚想用用mutt,不用自己找了,顶一个







__________________
there is common vision building our heart together,
there is common hope steering our feet in a common path!
  blithe 当前离线   回复时引用此帖
旧 05-09-13, 17:11 第 3 帖
roadgo
 
roadgo 的头像
 
 
版主  
  注册日期: May 2004
  帖子: 1,262
  精华: 3
 

能设置自己的smtp吗?







__________________
PII 赛阳300A,196M内存,4G硬盘,realtalk网卡两张,triend显卡,华硕mvp6主板

我的blog:[url]http://groups-beta.google.com/group/linuxroad/[/url]
  roadgo 当前离线   回复时引用此帖
旧 05-09-13, 17:16 第 4 帖
jamescsy
 
 
 
注册会员  
  注册日期: May 2005
  帖子: 102
  精华: 0
 

引用:
作者: roadgo
能设置自己的smtp吗?
自己作为smtp服务器?
当然可以啦,选择永远在线的选项,然后再网上查一下资料吧。
好像还是能找到的。
  jamescsy 当前离线   回复时引用此帖
旧 05-09-13, 17:35 第 5 帖
monpython
 
monpython 的头像
 
 
注册会员  
  注册日期: Nov 2002
  帖子: 513
  精华: 4
 

谢谢共享。
楼主要是能用颜色和代码格式,会更清晰可读。
俺有几个问题
引用:
作者: jamescsy
还要修改几个配置文件:
(1)/etc/exim4/passwd.client,smtp的帐号密码设置
加入:tomsmtp.163.net:邮箱帐号:邮箱密码(这里之所以是tomsmtp.163.net,而非smtp.tom.com,是因为ping smtp.tom.com时候,会显示tomsmtp.163.net。你不是tom.com的邮箱的话,请换成您自己的smtp服务器地址)
我有多个邮箱,可否设置每一个邮箱使用不同的smtp server ?

引用:
作者: jamescsy
(2)/etc/email-addresses,系统邮箱地址
加入:user: someone@isp.com,比如,我linux...mescsy@tom.com
问题同上。还是多个邮箱帐号的问题。

引用:
(3)/etc/exim4/exim4.conf.template,exim4配置文件
在最后加入一行:AUTH_CLIENT_ALLOW_NOTLS_PASSWORDS=1(意思是smtp的帐号密码以明文传输,因为目前大多数smtp服务器不支持tls,所以,加入这一行才能认证通过,这是关键,很多exim配置中都没提到)
我有两个gmail的帐号,它们都用tls的。如何设置?

引用:
(4)~/.muttrc,mutt配置文件
这里加入:
set envelope_from=yes
set sendmail="/usr/sbin/exim4"
set from=jamescsy@tom.com(根据你自己的邮箱,跟smtp服务器对应的帐号填写)
set realname="jameswang"
set use_from=yes
这样exim4算是设置好了,你可以通过mutt发邮件了。(当然,你可能需要dpkg-reconfigure exim4-config来重启一下mta,配置文件才能生效)
看来如果是多个邮箱,还是要用 send_hook 把回复地址改过来。

引用:
为了和word附件的配合,需要在.muttrc中加入:
auto_view application/msword
另外,还需要在~/.mailcap中加入:
text/html; lynx -force_html %s; needsterminal;
application/msword; /usr/bin/antiword '%s'; copiousoutput; #这里用到antiword,apt-get install就行
description="Microsoft Word Text"; nametemplate=%s.doc
这样,就能够在mutt中显示word附件了。
这个好。正是我想要的。


请楼主再接再厉,争取速出2.0版本。







__________________
与其咒骂黑暗不如点亮一只蜡烛。
----------------
12点以前睡觉;
先把必须要做的事做完;
多读自己的专业书;
开会的时候不要迟到;
  monpython 当前离线   回复时引用此帖
旧 05-09-13, 17:37 第 6 帖
monpython
 
monpython 的头像
 
 
注册会员  
  注册日期: Nov 2002
  帖子: 513
  精华: 4
 

补充问题:

不知exim的邮件队列功能怎样?

如果有一个很大的邮件没有发出去,它会如何处理?会不会阻隔后面的邮件?
  monpython 当前离线   回复时引用此帖
旧 05-09-13, 18:09 第 7 帖
jamescsy
 
 
 
注册会员  
  注册日期: May 2005
  帖子: 102
  精华: 0
 

网上关于简单配置exim4的资料实在太少,我也是花了好久时间才摸通了这么点点,楼上的问题,希望大家能够再接再厉,一块儿解决。
  jamescsy 当前离线   回复时引用此帖
旧 05-09-18, 17:08 第 8 帖
ha-exit
 
 
 
注册会员  
  注册日期: Mar 2005
  帖子: 171
  精华: 0
 

我按照你的设置,mutt发不了邮件阿,fetchmail也接不到邮件
发邮件时,看了exim4的日志,它显示如下:
fwyxww@163.com
smtp error from remote mail server after Mail FROM:<fwyxwww@163.com>:
host smtp.163.split.netease.com[202.108.44.205]:
533 You are not authorized to send mail as <MAIL FROM:<fwyxww@163.com>>,authentication is requried
我已经在client.passwd里加入了用户名和密码拉,同时也按照你的muttrc文件设置拉。

不知道怎么回事
  ha-exit 当前离线   回复时引用此帖
旧 05-09-18, 17:55 第 9 帖
halcyon79
 
halcyon79 的头像
 
 
注册会员  
  注册日期: May 2004
  帖子: 363
  精华: 0
 

代码:
我有多个邮箱,可否设置每一个邮箱使用不同的smtp server ?
这个我没有试过,不过我想似乎也有办法
代码:
问题同上。还是多个邮箱帐号的问题。
代码:
我有两个gmail的帐号,它们都用tls的。如何设置?
这个比较简单,只要在transport里修改一下port就可以了,gmail的port和普通的不太一样,是587端口,其它的要注意的是passwd.client,对于gmail要设置为:
gmail-smtp.l.google.com:account@gmail.comasswd的格式,否则smtp的验证不会通过的
代码:
看来如果是多个邮箱,还是要用 send_hook 把回复地址改过来。
我不知道你的意思是什么,我猜可能是想对于不同信箱收到的信,用该信箱地址回复?
那么只需要在muttrc里设置
set reverse_name=yes,注意不要使用my_hdr这个option,这个会是reverse_name失效

此帖于 05-09-18 18:00 被 halcyon79 编辑.
  halcyon79 当前离线   回复时引用此帖
旧 05-09-18, 17:59 第 10 帖
halcyon79
 
halcyon79 的头像
 
 
注册会员  
  注册日期: May 2004
  帖子: 363
  精华: 0
 

引用:
作者: ha-exit
我按照你的设置,mutt发不了邮件阿,fetchmail也接不到邮件
发邮件时,看了exim4的日志,它显示如下:
fwyxww@163.com
smtp error from remote mail server after Mail FROM:<fwyxwww@163.com>:
host smtp.163.split.netease.com[202.108.44.205]:
533 You are not authorized to send mail as <MAIL FROM:<fwyxww@163.com>>,authentication is requried
我已经在client.passwd里加入了用户名和密码拉,同时也按照你的muttrc文件设置拉。

不知道怎么回事
你试试把passwd.client里改成*:account: passwd的格式试试看

此帖于 05-09-18 18:08 被 halcyon79 编辑.
  halcyon79 当前离线   回复时引用此帖
旧 05-09-18, 18:07 第 11 帖
halcyon79
 
halcyon79 的头像
 
 
注册会员  
  注册日期: May 2004
  帖子: 363
  精华: 0
 

引用:
作者: jamescsy
Debian下默认装的是exim4,而且也说的很清楚,唯一可以取代exim的是postfix,不推荐使用sendmail和qmail。所以,还是配置默认的exim4来的好一些。下面是我的配置过程,希望对大家能有所帮助!
其实你现在说的还不够啊,这个配置的mutt具有了基本的功能,不过有很多都没有设置好,用起来会很不舒服,到时候可能碰到中文乱码、主题乱码等诸多问题的;另外mutt和procmail bogofilter接合对邮件、mail list分类、垃圾邮件过滤等,其实工作还是很多的;

另外现在muttrc里并不需要设置set sendmail="/usr/sbin/exim4"

此帖于 05-09-18 18:10 被 halcyon79 编辑.
  halcyon79 当前离线   回复时引用此帖
旧 05-09-18, 20:22 第 12 帖
ha-exit
 
 
 
注册会员  
  注册日期: Mar 2005
  帖子: 171
  精华: 0
 

刚才反复试验了楼主说的和楼上说的
需要指出来的以下:
1.AUTH_CLIENT_ALLOW_NOTLS_PASSWORDS=1
这个设置并不是在文件的最后,写在文件的最后丝毫不起作用。你可以查看/var/spool/exim4/mslog/文件夹里的日志,它会说认证错误。在/etc/exim4/exim4.conf.template,找到如下一段:
# These examples below are the equivalent for client side authentication.
# They get the passwords from CONFDIR/passwd.client. This file should have
# three columns separated by colons, the first contains the name of the
# mailserver to authenticate against, the second the username and the third
# contains the password.

### # example for CONFDIR/passwd.client
### mail.server:blah:secret
### # default entry:
### *:bar:foo
大家可以仔细的看这一段,它说的是这个位置的配置是exim作为客户短认证时的设置,下面就是一些脚本拉,因此需要在这里设置:AUTH_CLIENT_ALLOW_NOTLS_PASSWORDS=1,这样下面的脚本才可能根据这个来
判断执行,因此,如果你加在最后,显然是不起任何作用的,因此exim4在执行玩脚本之后才看到AUTH_CLIENT_ALLOW_NOTLS_PASSWORDS=1。

2.passwd.client
上面的引用中可以看到passwd.client的设置方法,我试了一下楼主的方法,刚开始的时候设为smtp.163.com,发现不起作用,改为实际的地址smtp.163.split.netease.com可以起作用,并且你用*:longinasswd(longin是你的用户名,passwd是你的密码)是可以顺利发送的,仔细思考了一下,弄明白了,因为在执行
了dpkg-reconfigure exim4-config的时候我们已经告诉了exim4邮件服务器的域名,它不需要你再告诉它,

3.mutt
muttrc文件里确实不需要set sendmail="/usr/sbin/exim4",因为我们在dpkg-reconfigure exim4-config时就等于告诉系统用exim4发送邮件

4.关于乱码
如果你用的term是mlterm的话,并且locale是zh_CN.UTF-8的话,不需要进行任何设置就可以看到中文,而且你可以在里面输入中文,绝对不乱吗。
  ha-exit 当前离线   回复时引用此帖
旧 05-09-18, 20:43 第 13 帖
halcyon79
 
halcyon79 的头像
 
 
注册会员  
  注册日期: May 2004
  帖子: 363
  精华: 0
 

有关明文验证的东西我在newsmth.net上写过一篇文章是讲这个的,我看作者似乎提到了
AUTH_CLIENT_ALLOW_NOTLS_PASSWORDS=1选项,我也就没有注意。

有关passwd.client的问题,按道理来说指定了smtp.163.com应该是可以的,但是实际上不行,这个好象是exim4的一个bug,mail list上有讨论

另外乱码问题,我说的中文乱码并不是一般的中文显示不了,你慢慢用吧,总会碰到的,呵呵
  halcyon79 当前离线   回复时引用此帖
旧 05-09-19, 09:23 第 14 帖
jamescsy
 
 
 
注册会员  
  注册日期: May 2005
  帖子: 102
  精华: 0
 

关于明文验证,我想主要是设置3个地方:
1、AUTH_CLIENT_ALLOW_NOTLS_PASSWORDS=1,位置应该紧跟在
# Because AUTH PLAIN and AUTH LOGIN send the password in clear, we
# only allow these mechanisms over encrypted connections by default.
# You can set AUTH_CLIENT_ALLOW_NOTLS_PASSWORDS to allow unencrypted
# clear text password authentication on all connections.
下面。(其实我自己是这么设置的,不过有看到文章说加在最后就行,我也就没有验证过了)

2、/etc/exim4/passwd.client里面的smtp服务器,一定要设置实际地址,可以通过ping smtp.xyz.com来获得该smtp服务器的真实地址。

3、~/.muttrc,mutt配置文件这里加入:
set envelope_from=yes
set sendmail="/usr/sbin/exim4"
set from=jamescsy@tom.com(根据你自己的邮箱,跟smtp服务器对应的帐号填写)
set realname="jameswang"
set use_from=yes
填入from对应smtp服务器的帐号。
  jamescsy 当前离线   回复时引用此帖
旧 05-09-19, 12:42 第 15 帖
guoke 帅哥
 
guoke 的头像
 
 
注册会员  
  注册日期: Apr 2005
  我的住址: 洛阳
  帖子: 106
  精华: 0
 

我加了 AUTH_CLIENT_ALLOW_NOTLS_PASSWORDS=1 后,配置怎么也通不过,提示错误:
configuration error in line 395 of /var/lib/exim4/config.autogenerated.tmp:
authenticator name missing

打开 /etc/exim4/exim4.conf.template
找到这里:
# Because AUTH PLAIN sends the password in clear, per default we only allow it
# over encrypted connections. If you want to change this disable the existing
# "client send" entry and enable the one below without the "if !eq{$tls_cipher}{}"
# by removing the hash-mark (#) at the beginning of the line.

它的意思是说,要用明文验证,只需要把下面的带 "if !eq{$tls_cipher}{}" 的 client_send 有关的注释掉(每一行都要注释掉),再去掉不带 "if !eq{$tls_cipher}{}" 的 client_send 前的注释.结果看上去就像这样:

plain:
driver = plaintext
public_name = PLAIN
# client_send = "${if !eq{$tls_cipher}{}{\
# ^${extract{1}{::}\
# {${lookup{$host}lsearch*{CONFDIR/passwd.client}{$value}fail}}}\
# ^${extract{2}{::}\
# {${lookup{$host}lsearch*{CONFDIR/passwd.client}{$value}fail}}}\
# }fail}"
client_send = "^${extract{1}{::}{${lookup{$host}lsearch*{CONFDIR/passwd.client}{$value}fail}}}^${extract{2}{::}{${lookup{$host}lsearch*{CONFDIR/passwd.client}{$value}fail}}}"

这样就行了,不需要 AUTH_CLIENT_ALLOW_NOTLS_PASSWORDS=1

另外,能通过exim发邮件后,又遇到了一个问题,一些系统内部的邮件比如root的邮件会通过exim发到 root@163.com,当然它发不出去. 这怎么办呢?







__________________
Were you wondering was the gamble worth the price?

此帖于 05-09-19 13:01 被 guoke 编辑.
  guoke 当前离线   回复时引用此帖
发表新主题 回复


主题工具

发帖规则
您 [不可以] 发表新主题
您 [不可以] 回复主题
您 [不可以] 上传附件
您 [不可以] 编辑您的帖子

已 [启用] BB 代码
已 [启用] 表情符号
已 [启用] IMG 代码
已 [禁用] HTML 代码
[论坛跳转…]


所有时间均为[北京时间]。现在的时间是 21:31


Powered by vBulletin 版本 3.6.8
版权所有 ©2000 - 2010, Jelsoft Enterprises Ltd.
官方中文技术支持: vBulletin 中文
版权所有 ©2002 - 2009, LinuxSir.Org