`
eimhee
  • 浏览: 2110190 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

ubuntu 下安装邮件服务器EXIM4+dovecot

阅读更多

先简单介绍一下EXIM4, EXIM4 是一个邮件传送代理(MTA), EXIM4可以替代linux 下的SendEmail, 配置很简单,

需要注意的是EXIM4只是用来传送邮件, 收取邮件需要安装POP, IMAP软件。

 

官方解释

exim 写道
Exim is a message transfer agent (MTA) developed at the University of Cambridge for use on Unix systems connected to the Internet. It is freely available under the terms of the GNU General Public Licence. In style it is similar to Smail 3, but its facilities are more general. There is a great deal of flexibility in the way mail can be routed, and there are extensive facilities for checking incoming mail. Exim can be installed in place of Sendmail, although the configuration of Exim is quite different.

 

 

关于EXIM4的中文资料比较少, 我发了不少时间在这上面,才配置好了。

 

设置DNS解析添加MX记录

我这里用的是bind 9 ,

配置如下:

 

@ IN NS example.com.
@ IN MX mail.example.com.
mail IN A 46.249.37.131

 

反向解析, 这一步骤不是必须的, 但如果你不想GOOGLE把你的邮件当垃圾服务器, 这个需要加上

 

@ IN NS example.com.
131 IN PTR example.com.
131 IN PTR mail.example.com.

 

remove sendmail

rm -f /usr/lib/sendmail

 

 

安装 EXIM4

 
Install the exim4 package from the Main repository using your favorite package manager (see InstallingSoftware).
 
sudo apt-get install exim4

 

配置EXIM4使用下面这个命令

 

 
sudo dpkg-reconfigure exim4-config

 

 

The user interface will be displayed. The user interface lets you configure many parameters. For example, In exim4 the configuration files are split among multiple files. If you wish to have them in one file you can configure accordingly in this user interface.

All the parameters you configure in the user interface are stored in /etc/exim4/update-exim4.conf.conf file. If you wish to re-configure the program, either re-run the configuration wizard or manually edit this file using your favourite editor. Run the following command to generate the master configuration file:

 

 

SMTP Authentication

利用OPENSSl生成证书

 
sudo /usr/share/doc/exim4-base/examples/exim-gencert

 

编辑 /etc/exim4/conf.d/main/03_exim4-config_tlsoptions

在最后面加上

 
MAIN_TLS_ENABLE = yes

 

编辑 /etc/exim4/conf.d/auth/30_exim4-config_examples

去掉 plain_saslauthd_server 和 login_saslauthd_server 的注释

 

 
plain_saslauthd_server:
driver = plaintext
public_name = PLAIN
server_condition = ${if saslauthd{{$auth2}{$auth3}}{1}{0}}
server_set_id = $auth2
server_prompts = :
.ifndef AUTH_SERVER_ALLOW_NOTLS_PASSWORDS
server_advertise_condition = ${if eq{$tls_cipher}{}{}{*}}
.endif
#
login_saslauthd_server:
driver = plaintext
public_name = LOGIN
server_prompts = "Username:: : Password::"
# don't send system passwords over unencrypted connections
server_condition = ${if saslauthd{{$auth1}{$auth2}}{1}{0}}
server_set_id = $auth1
.ifndef AUTH_SERVER_ALLOW_NOTLS_PASSWORDS
server_advertise_condition = ${if eq{$tls_cipher}{}{}{*}}
.endif

 

最后重启EXIM4

 
sudo update-exim4.conf
sudo /etc/init.d/exim4 restart

 

 

设置SASL

Configuring SASL

 

首先安装sasl2-bin

sudo apt-get install sasl2-bin

 

编辑/etc/default/saslauthd, 让SAS能启动

 
START=yes

 

安装后会自动生成一个用 Debian-exim

把它加入组,不然会没有权限的

 
sudo adduser Debian-exim sasl

 

重起SASL

 
sudo /etc/init.d/saslauthd start

 Exim4 is now configured with SMTP AUTH using TLS and SASL authentication.

 

EXIM4就实现了SMTP验证和使用TLS

 

 

这个时候EXIM4的配置应该是这样的  vi /etc/exim4/update-exim4.conf.conf

dc_eximconfig_configtype='internet'
dc_other_hostnames='inkebook.com'
dc_local_interfaces='127.0.0.1:46.249.37.131'
dc_readhost=''
dc_relay_domains='*'
dc_minimaldns='false'
dc_relay_nets='admin@inkebook.com'
dc_smarthost=''
CFILEMODE='644'
dc_use_split_config='false'
dc_hide_mailname=''
dc_mailname_in_oh='true'
dc_localdelivery='maildir_home'

 

先测试一下能不能发邮件

 

 
echo "my test" | mail -s "test message" admin@inkebook.com

 

tail -f /var/log/exim4

 如果发送成功, 会在日志当中显示出来

 

 

这个时候用客户端还不是收发邮件的, 还需要装dovecot或者courier, 这里用courier

 

apt-get install courier-imap courier-imap-ssl

 

为了让POP也支持, 安装

 

apt-get install courier-pop and courier-pop-ssl

 

生成邮件目录

cd ~
maildirmake Maildir
maildirmake Maildir/.Drafts
maildirmake Maildir/.Sent
maildirmake Maildir/.Trash
maildirmake Maildir/.Templates
chmod -R 700 Maildir

 

现在我们可以用outlook foxmail 来测试了。

 

如果saslauthd认证有问题, 可以用下面方法调试

 

testsaslauthd -f /var/spool/postfix/var/run/saslauthd/mux -u username -p password

 

 

 

我们的邮件服务器到此就配置好了, 可以说在LINUX下配置邮件服务器是一件比较难的事情, 需要这么多步骤。

 

 

1
1
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics