考虑到以后ucenter home的邮箱注册激活功能或许能实现,所以在家搭建了exim4,通过google的smtp来转发,果然,google的速度是一流的。现在把基本的配置记下来,以备后用。
服务器是debian,用apt-get安装exim4,exim4-config,exim4-daemon-light
之后配置/etc/exim4/update-exim4.conf.conf,配置文件如下:
dc_eximconfig_configtype='smarthost' #用smarthost发信;通过SMTP或fetchmail接收信件
dc_other_hostnames=''
dc_local_interfaces='127.0.0.1' #只接收本机的SMTP请求,只在本机使用Exim4
dc_readhost=''
dc_relay_domains=''
dc_minimaldns='false'
dc_relay_nets=''
dc_smarthost='smtp.gmail.com' #gmail的smtp主机
CFILEMODE='644'
dc_use_split_config='false' #不使用分散方式的配置文件
dc_hide_mailname='false'
dc_mailname_in_oh='true'
dc_localdelivery='mail_spool'
然后编辑/etc/mailname,也就是@后面的那一段了。
运行update-exim4.conf来检测配置段落是否有错误,没有的话就会生成/var/lib/exim4/config.autogenerated,之后用exim -bV来查看:
Exim version 4.63 #1 built 20-Jan-2007 10:40:39
Copyright (c) University of Cambridge 2006
Berkeley DB: Sleepycat Software: Berkeley DB 4.3.29: (September 6, 2005)
Support for: crypteq iconv() IPv6 GnuTLS move_frozen_messages
Lookups: lsearch wildlsearch nwildlsearch iplsearch cdb dbm dbmnz dsearch nis nis0 passwd
Authenticators: cram_md5 plaintext
Routers: accept dnslookup ipliteral manualroute queryprogram redirect
Transports: appendfile/maildir/mailstore autoreply lmtp pipe smtp
Fixed never_users: 0
Size of off_t: 8
Configuration file is /var/lib/exim4/config.autogenerated
测试一下外部发送邮件
exim4 -bt yoyoliyang@gmail.com
from:root
to:shouguang@shouguang.org
subject:local mail test
test will be ok.
.
LOG: MAIN
<= root@shouguang.org U=root P=local S=380
debian:/home/shouguang# delivering 1KrNb4-0006Rp-Uc
R: smarthost for shouguang@shouguang.org
T: remote_smtp_smarthost for shouguang@shouguang.org
Connecting to gmail-smtp-msa.l.google.com [209.85.143.111]:25 ... connected
SMTP<< 220 mx.google.com ESMTP 2sm3024427tif.0
SMTP>> EHLO debian.shouguang.org
SMTP<< 250-mx.google.com at your service, [221.1.80.22]
250-SIZE 35651584
250-8BITMIME
250-STARTTLS
250 ENHANCEDSTATUSCODES
SMTP>> STARTTLS
SMTP<< 220 2.0.0 Ready to start TLS
SMTP>> EHLO debian.shouguang.org
SMTP<< 250-mx.google.com at your service, [221.1.80.22]
250-SIZE 35651584
250-8BITMIME
250-AUTH LOGIN PLAIN
250 ENHANCEDSTATUSCODES
SMTP>> MAIL FROM: SIZE=1414
SMTP<< 530-5.5.1 Authentication Required. Learn more at
530 5.5.1 http://mail.google.com/support/bin/answer.py?answer=14257 2sm3024427tif.0
SMTP>> QUIT
LOG: MAIN
** shouguang@shouguang.org R=smarthost T=remote_smtp_smarthost: SMTP error from remote mail server after MAIL FROM: SIZE=1414: host gmail-smtp-msa.l.google.com [209.85.143.111]: 530-5.5.1 Authentication Required. Learn more at\n530 5.5.1 http://mail.google.com/support/bin/answer.py?answer=14257 2sm3024427tif.0
LOG: MAIN
<= <> R=1KrNb4-0006Rp-Uc U=Debian-exim P=local S=1464
LOG: MAIN
Completed
实际上报错,这很正常,因为我们要经过smtp.gmail.com的用户验证。
修改/etc/exim4/passwd.client(仅root可看),按照举例添加smtp地址和用户名密码,google的smtp真实地址为:gmail-smtp-msa.l.google.com。
修改/etc/exim4/email-addresses,添加用户对应的外部地址。
root:user[at]gmail.com
如果对应的smtp服务器要求明文验证密码,需要更改/etc/exim4/exim4.conf.template,gmail不需要更改。
# clear text password authentication on all connections.
AUTH_CLIENT_ALLOW_NOTLS_PASSWORDS = 1
之后重启exim4服务,可以顺便测试一下。
sendmail_path = sendmail -t
好了。经密码找回测试,成功。
没有评论:
发表评论