本文版权归作者所有,如其他个人、第三方网站或媒体报刊等需转载全文或节选,为支持我们的工作,请务必注明如下信息:
如果因此而给您带来麻烦,请您原谅,谢谢合作。本文档以2005-07-25的早期文档为蓝本,以ports系统为基础。所涉及软件全部是OpenSource软件,版权以GPL为主,作为企业应用没有任何版权/法律问题。
编写本文的初衷,是给那些希望快速架设邮件系统而不想过多了解复杂的系统知识的网管/用户,为了使软件之间的结合更紧密,部分软件的配置及测试方面进行了增强改进,因此本文的一些操作步骤作者不能保证在其他场合能完全适用,敬请注意。
本文假定读者是在FreeBSD 6.x平台上安装,并具有一定的Unix平台 /FreeBSD平台系统经验,懂得ports基本命令及常规的系统操作,如文件的删除,目录创建,改名,和vi编辑器的基本使用等。
ExtMail Solution 是一个基于优秀开源软件的电子邮件系统解决方案,核心部件包括了Postfix, Amavisd-new, ClamAV, ExtMail 和ExtMan, Courier系列软件。是一个功能相对比较齐全的免费电子邮件系统。以下是其主要的特性列表:
整个邮件解决方案由如下软件组成:
功能模块 | 内容 | 备注 |
操作系统(OS) | FreeBSD 6.x | FreeBSD是一个优秀的unix操作系统,基于宽松的BSD协议 |
邮件传输代理(MTA) | Postfix 2.3 | 使用2.3,ports中的postfix已经是最新的2.3版 |
数据库/目录服务 | OpenLDAP 2.3 | 可选MySQL或其他LDAP ,本文以OpenLDAP为蓝本 |
邮件投递代理(MDA) | maildrop 2.0.x | 支持过滤和强大功能 |
Web帐户管理后台 | ExtMan 0.16-pre1 | 支持无限域名、无限用户 |
POP3 服务器 | Courier-IMAP | 支持pop3/pop3s/imap/imaps,功能强大,可根据需要选择 |
WebMail 系统 | ExtMail 0.24-pre8 | 支持多语言、全部模板化,功能基本齐全 |
防病毒软件(Anti-Virus) | ClamAV 0.88 | 最热门的开源杀毒软件 |
SMTP阶段反垃圾邮件工具 | Spam Locker 0.083 | 基于SMTP行为识别的Antispam软件,大量可选插件 |
内容过滤器 | Amavisd-new 2.4.x | Content-Filter软件,支持与clamav/sa的挂接 |
内容级别的反垃圾邮件工具 | SpamAssassin | 著名的SA,可以支持大量规则,但速度慢 |
SMTP认证库 | Cyrus SASL 2.1x | 标准的SASL实现库,可以支持Courier authlib |
其他数据认证库 | Courier Authlib 0.58 | authlib是maildrop, courier-imap等服务的关键部件 |
日志分析及显示 | mailgraph_ext | 在ExtMan中已经包含了 |
Web 服务器 | Apache 2.2.x | 最新版的apache服务器,默认支持ssl模块 |
maillist软件 | Mailman2.1.x | 功能强大的邮件列表软件,支持基于web的管理 |
操作系统的安装建议参考FreeBSD Handbook,在此仅给出链接,以避免不必要的重复劳动:
1,磁盘分区
由于是邮件系统,相关的日志和queue都会保存在var分区内,因此var分区要有足够的空间。以一块硬盘73G/内存2G的服务器为例,可做如下分区:
/ 512mswap 4096m /var 55g/tmp 512m/usr 13g(剩下所有的空间尽量保证有10G左右)
2,软件包的选择
我们的邮件系统是要对外服务的,所以尽可能少的选择软件包,安装时建议选择Minimal,然后进入Custom选择doc,info,man,src即可。
1,编辑/etc/rc.conf确保有如下内容:
sshd_enable="YES"named_enable="YES"sendmail_enable="NONE"编辑/etc/resolv.conf确保第一条nameserver记录是127.0.0.1,类似如下:
domain extmail.orgnameserver 127.0.0.1nameserver 202.106.0.20然后执行如下命令:
2,根据硬件的配置重新编译内核,编译内核的办法参考FreeBSD Handbook,这里只给出链接:
根据你的情况执行
整个系统的安装全过程都要求以root身份执行,如果机器没有访问外部网络的能力,则事先下载好ExtMail Solution软件包,并用ftp以sysadmin帐户的身份,上载到服务器。
su - cd /rootfetch http://www.extmail.org/source/ExtMail-Solution-FreeBSD-0.1.tar.gz
对下载的文件做以下md5校验,确保文件在下载的过程中是完整的。
fetch http://www.extmail.org/source/md5sum.es_freebsd-0.1md5 ExtMail-Solution-FreeBSD-0.1.tar.gz如果md5生成的字符串和fetch下来的md5值一样,则说明下载的过程中没有问题。由于软件包不断的变更,所以上述结果和您的结果可能不一致,请以下载的md5sum为准。
目前最新的ExtMail-Solution软件包版本号为0.1,软件包文件名为:ExtMail-Solution-FreeBSD-0.1.tar.gz,下载回来后,在/root目录解开:
此外,我们假设本次安装默认域是extmail.org,主机名为:mail.extmail.org,IP地址为192.168.1.111, ExtMail Solution的文件目录是/root/ExtMail-Solution-0.1/
我们进入/root/ExtMail-Solution-0.1/目录,该目录下包括如下文件/目录:
conf/docs/src/README
其中conf/目录是相关配置文件的一个参考,src目录则是存放webmail, anti-spam等相关软件的源码,而README则是说明文件,docs目录则是本文档相关的html及图片。
下文所涉及的操作,绝大部分都是发生在/root/ExtMail-Solution-0.1目录里,请确保当前目录为:/root/ExtMail-Solution-0.1
pw group add vmail -g 1000pw user add vmail -u 1000 -g 1000 -s /sbin/nologin -d /dev/null
mkdir -p /var/domains/extmail.org/test/Maildir/newmkdir -p /var/domains/extmail.org/test/Maildir/curmkdir -p /var/domains/extmail.org/test/Maildir/tmpchown -R vmail:vmail /var/domains/chmod -R 700 /var/domains/
安装时选择:
SASLTCP_WRAPPERSBDBDYNAMIC_BACKENDSSLUPD
编辑/etc/hosts或者修改你的DNS服务器,增加如下两个域名。
192.168.1.111 ldap.extmail.org192.168.1.111 ldap-master.extmail.org
拷贝extmail.schema到OpenLDAP的schema目录
编辑/usr/local/etc/openldap/slapd.conf文件,内容类似如下:
include /usr/local/etc/openldap/schema/core.schemainclude /usr/local/etc/openldap/schema/cosine.schemainclude /usr/local/etc/openldap/schema/nis.schemainclude /usr/local/etc/openldap/schema/extmail.schemapidfile /var/run/openldap/slapd.pidargsfile /var/run/openldap/slapd.argsdatabase bdbsuffix "dc=extmail.org"rootdn "cn=Manager,dc=extmail.org"rootpw secretdirectory /var/db/openldap-dataindex objectClass eq
编辑/usr/local/etc/openldap/ldap.conf文件,内容类似如下:
BASE dc=extmail.orgURI ldap://ldap.extmail.org ldap://ldap-master.extmail.org:398SIZELIMIT 12TIMELIMIT 15DEREF never
编辑/etc/rc.conf,增加如下一行
启动并初始化LDAP
/usr/local/etc/rc.d/slapd startldapadd -x -D 'cn=Manager,dc=extmail.org' -w secret -f conf/init.ldif
OpenLDAP配置完成
安装时选择:
OPENSSLTRASHQUOTAAUTH_LDAP
编辑/usr/local/etc/authlib/authdaemonrc文件,内容类似如下:
authmodulelist="authldap"authmodulelistorig="authldap"daemons=5authdaemonvar=/var/run/authdaemondsubsystem=mailDEBUG_LOGIN=0DEFAULTOPTIONS="wbnodsn=1"LOGGEROPTS=""增加/var/run/authdaemond的执行权限,在FreeBSD系统下,其他用户默认没有执行权限
LDAP_URI ldap://ldap.extmail.orgLDAP_PORT 389LDAP_PROTOCOL_VERSION 3LDAP_BASEDN o=extmailAccount,dc=extmail.org LDAP_BINDDN cn=Manager,dc=extmail.orgLDAP_BINDPW secretLDAP_TIMEOUT 5LDAP_MAIL mailLDAP_FILTER (active=1)LDAP_GLOB_UID vmailLDAP_GLOB_GID vmailLDAP_HOMEDIR homeDirectoryLDAP_MAILROOT /var/domainsLDAP_MAILDIRQUOTA mailQuotaLDAP_CRYPTPW userPasswordLDAP_DEREF neverLDAP_TLS 0
RANDFILE = /usr/local/share/courier-imap/pop3d.rand[ req ]default_bits = 1024encrypt_key = yesdistinguished_name = req_dnx509_extensions = cert_typeprompt = no[ req_dn ]C=CNST=BJL=Bei JingO=ExtmailOU=ExtmailCN=extmail.orgemailAddress=chifeng@gmail.com[ cert_type ]nsCertType = server执行如下命令产生供POP3s使用的key
拷贝一份配置文件
RANDFILE = /usr/local/share/courier-imap/imapd.rand[ req ]default_bits = 1024encrypt_key = yesdistinguished_name = req_dnx509_extensions = cert_typeprompt = no[ req_dn ]C=CNST=BJL=Bei JingO=ExtmailOU=ExtmailCN=extmail.orgemailAddress=chifeng@gmail.com[ cert_type ]nsCertType = server执行如下命令产生供IMAP使用的key
编辑/etc/rc.conf文件,添加如下行:
courier_authdaemond_enable="YES"courier_imap_pop3d_enable="YES"courier_imap_imapd_enable="YES"courier_imap_pop3d_ssl_enable="YES"courier_imap_imapd_ssl_enable="YES"这5行的作用分别是在开机时:启动authdaemond,启动pop3d,启动imapd,启动pop3d-ssl,启动imapd-ssl。也可以使用命令行来控制这些进程的启动或者停止。
/usr/local/etc/rc.d/courier-authdaemond start/stop/usr/local/etc/rc.d/courier-imap-pop3d.sh start/stop/usr/local/etc/rc.d/courier-imap-imapd.sh start/stop/usr/local/etc/rc.d/courier-imap-pop3d-ssl.sh start/stop/usr/local/etc/rc.d/courier-imap-imapd-ssl.sh start/stop
安装时选择:
PCRESASL2TLSOPENLDAPVDATEST
编辑/etc/rc.conf,增加如下一行
mv /usr/sbin/sendmail /usr/sbin/sendmail.bakcp /usr/local/sbin/sendmail /usr/sbin/sendmail编辑/etc/periodic.conf
daily_clean_hoststat_enable="NO"daily_status_mail_rejects_enable="NO"daily_status_include_submit_mailq="NO"daily_submit_queuerun="NO"执行如下命令
newaliaseschown postfix:postfix /etc/opiekeyspostconf -e 'mydomain = extmail.org'postconf -e 'myhostname = mail.extmail.org'postconf -e 'myorigin = $mydomain'postconf -e 'virtual_mailbox_base = /var/domains'postconf -e 'virtual_uid_maps=static:1000'postconf -e 'virtual_gid_maps=static:1000'
编辑/usr/local/etc/postfix/ldap_virtual_alias_maps.cf
server_host = localhostsearch_base = o=extmailAlias,dc=extmail.orgquery_filter = (&(objectClass=extmailAlias)(mailLocalAddress=%s)(active=1))result_attribute = mailcache = nobind = noscope = sub编辑/usr/local/etc/postfix/ldap_virtual_mailbox_maps.cf
server_host = localhostsearch_base = o=extmailAccount,dc=extmail.orgquery_filter = (&(objectClass=extmailUser)(mail=%s)(active=1))result_attribute = mailMessageStorecache = nobind = noscope = sub编辑/usr/local/etc/postfix/ldap_virtual_domains_maps.cf
server_host = localhostsearch_base = o=extmailAccount,dc=extmail.orgquery_filter = (&(objectClass=extmailDomain)(virtualDomain=%s)(active=1))result_attribute = virtualDomaincache = nobind = noscope = sub执行如下命令对查询表进行配置
postconf -e 'virtual_alias_maps = $alias_maps, ldap:/usr/local/etc/postfix/ldap_virtual_alias_maps.cf'postconf -e 'virtual_mailbox_maps = ldap:/usr/local/etc/postfix/ldap_virtual_mailbox_maps.cf'postconf -e 'virtual_mailbox_domains = ldap:/usr/local/etc/postfix/ldap_virtual_domains_maps.cf'
编辑/usr/local/lib/sasl2/smtpd.conf
pwcheck_method:authdaemondlog_level:3mech_list:PLAIN LOGINauthdaemond_path:/var/run/authdaemond/socket对postfix做如下配置使支持smtp认证
postconf -e 'smtpd_sasl_auth_enable=yes'postconf -e 'broken_sasl_auth_clients = yes'postconf -e 'smtpd_sasl_local_domain = $myhostname'
此处的反垃圾邮件只是在MTA级的一些预防垃圾邮件的设置,可根据实际情况以及自己的需要进行调整。
postconf -e 'smtpd_helo_required=yes'postconf -e 'smtpd_delay_reject=yes'postconf -e 'disable_vrfy_command=yes'postconf -e 'smtpd_client_restrictions = check_client_access hash:/usr/local/etc/postfix/client_access'postconf -e 'smtpd_helo_restrictions=reject_invalid_hostname,check_helo_access hash:/usr/local/etc/postfix/helo_access'postconf -e 'smtpd_sender_restrictions = reject_non_fqdn_sender, reject_unknown_sender_domain, check_sender_access hash:/usr/local/etc/postfix/sender_access'postconf -e 'smtpd_recipient_restrictions=permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, reject_non_fqdn_recipient, reject_unknown_recipient_domain'postconf -e 'smtpd_data_restrictions=reject_unauth_pipelining'postconf -e 'header_checks = regexp:/usr/local/etc/postfix/head_checks'postconf -e 'body_checks = regexp:/usr/local/etc/postfix/body_checks'touch /usr/local/etc/postfix/head_checkstouch /usr/local/etc/postfix/body_checkstouch /usr/local/etc/postfix/client_accesstouch /usr/local/etc/postfix/sender_accesstouch /usr/local/etc/postfix/helo_accesspostmap /usr/local/etc/postfix/head_checkspostmap /usr/local/etc/postfix/body_checkspostmap /usr/local/etc/postfix/client_accesspostmap /usr/local/etc/postfix/sender_accesspostmap /usr/local/etc/postfix/helo_access
生成证书,在这里默认私钥的访问密码为123qwe98,请根据自己的情况决定,以后可能会用得到。
mkdir -p /usr/local/etc/postfix/certs/CAcd /usr/local/etc/postfix/certs/CAmkdir certs crl newcerts privateecho "01" > serialtouch index.txtcp /usr/src/crypto/openssl/apps/openssl.cnf .编辑openssl.cnf,确认dir参数的值是/usr/local/etc/postfix/certs/CA。然后继续执行如下命令,并根据情况输入信息。输入信息类似如下:
Country Name (2 letter code) [AU]:CNState or Province Name (full name) [Some-State]:BJLocality Name (eg, city) []:Bei JingOrganization Name (eg, company) [Internet Widgits Pty Ltd]:ExtmailOrganizational Unit Name (eg, section) []:extmailCommon Name (eg, YOUR name) []:extmail.orgEmail Address []:chifeng@gmail.com命令如下:
openssl req -new -x509 -keyout private/cakey.pem -out cacert.pem -days -3650 -config openssl.cnf openssl req -nodes -new -x509 -keyout mykey.pem -out myreq.pem -days 3650 -config openssl.cnfopenssl x509 -x509toreq -in myreq.pem -signkey mykey.pem -out tmp.pemopenssl ca -config openssl.cnf -policy policy_anything -out mycert.pem -infiles tmp.pemrm tmp.pemcp cacert.pem mycert.pem mykey.pem /usr/local/etc/postfix/certs/cd /usr/local/etc/postfix/certs/chown root:wheel cacert.pem mycert.pemchown cyrus:postfix mykey.pemchmod 755 cacert.pemchmod 644 mycert.pemchmod 440 mykey.pemln -s cacert.pem `openssl x509 -noout -hash < cacert.pem `.0
配置postfix支持TLS
postconf -e 'smtpd_use_tls=yes'postconf -e 'smtpd_tls_auth_only=no'postconf -e 'smtp_tls_CAfile = /usr/local/etc/postfix/certs/cacert.pem'postconf -e 'smtp_tls_cert_file = /usr/local/etc/postfix/certs/mycert.pem'postconf -e 'smtp_tls_key_file = /usr/local/etc/postfix/certs/mykey.pem'postconf -e 'smtpd_tls_CAfile=/usr/local/etc/postfix/certs/cacert.pem'postconf -e 'smtpd_tls_cert_file=/usr/local/etc/postfix/certs/mycert.pem'postconf -e 'smtpd_tls_key_file=/usr/local/etc/postfix/certs/mykey.pem'postconf -e 'smtpd_tls_received_header=yes'postconf -e 'smtpd_tls_loglevel=3'postconf -e 'smtpd_starttls_timeout=60s'
配置master.cf,添加如下信息
smtps inet n - n - - smtpd -o smtpd_tls_wrappermode=yes -o smtpd_sasl_auth_enable=yes -o smtpd_client_restrictions=permit_sasl_authenticated,reject
#maildrop unix - n n - - pipe# flags=DRhu user=vmail argv=/usr/local/bin/maildrop -d ${recipient}maildrop unix - n n - - pipe flags=DRhu user=vmail:vmail argv=/usr/local/bin/maildrop -w 90 -d ${recipient}
postconf -e 'virtual_transport=maildrop:'postconf -e 'maildrop_destination_concurrency_limit=1'postconf -e 'maildrop_destination_recipient_limit=1'
logfile "/var/domains/maildrop.log"#logfile "/var/log/maildrop.log"TEST="/bin/test -f"## Check for custom user .mailfilter file#CUSTOM_FILTER="$HOME/.mailfilter"`$TEST $CUSTOM_FILTER && exit 1 || exit 0`if ( $RETURNCODE == 0 ){ to "$HOME/Maildir"}
THREADSHUGE_STACK_SIZEUCS4PYMALLOCFPECTL
User vmailGroup vmail
NameVirtualHost *:80<VirtualHost *:80> ServerName mail.extmail.org DocumentRoot /usr/local/www/extmail/html/ ScriptAlias /extmail/cgi /usr/local/www/extmail/cgi/ Alias /extmail /usr/local/www/extmail/html/ ScriptAlias /extman/cgi "/usr/local/www/extman/cgi/" Alias /extman "/usr/local/www/extman/html/" <Location "/extman/cgi"> SetHandler cgi-script Options +ExecCGI AllowOverride All </Location> <Directory "/usr/local/www"> AllowOverride None Options None Order allow,deny Allow from all </Directory># SuexecUserGroup vmail vmail</VirtualHost>
mkdir /usr/local/etc/apache22/certs/cp /usr/local/etc/postfix/certs/*.pem /usr/local/etc/apache22/certs/编辑文件/usr/local/etc/apache22/Includes/extmail-ssl.conf,内容如下
Listen 443AddType application/x-x509-ca-cert .crtAddType application/x-pkcs7-crl .crlSSLPassPhraseDialog builtinSSLSessionCache shmcb:/var/run/ssl_scache(512000)SSLSessionCacheTimeout 300SSLMutex file:/var/run/ssl_mutex<VirtualHost _default_:443>DocumentRoot "/usr/local/www/extmail/html"ServerName mail.extmail.org:443ScriptAlias /extmail/cgi /usr/local/www/extmail/cgi/Alias /extmail /usr/local/www/extmail/html/ScriptAlias /extman/cgi "/usr/local/www/extman/cgi/"Alias /extman "/usr/local/www/extman/html/"ServerAdmin chifeng@gmail.comErrorLog /var/log/httpd-error.logTransferLog /var/log/httpd-access.logSSLEngine onSSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL#SSLCertificateFile /usr/local/etc/apache22/server.crt#SSLCertificateKeyFile /usr/local/etc/apache22/server.keySSLCertificateFile /usr/local/etc/apache22/certs/mycert.pemSSLCertificateKeyFile /usr/local/etc/apache22/certs/mykey.pem<FilesMatch "\.(cgi|shtml|phtml|php)$"> SSLOptions +StdEnvVars</FilesMatch><Directory "/usr/local/www/apache22/cgi-bin"> SSLOptions +StdEnvVars</Directory>BrowserMatch ".*MSIE.*" \ nokeepalive ssl-unclean-shutdown \ downgrade-1.0 force-response-1.0CustomLog /var/log/httpd-ssl_request.log \ "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"#SuexecUserGroup vmail vmail</VirtualHost>重起一下apache
SYS_CONFIG = /usr/local/www/extman/ SYS_LANGDIR = /usr/local/www/extman/lang SYS_TEMPLDIR = /usr/local/www/extman/html SYS_MAILDIR_BASE = /var/domains SYS_PSIZE = 50SYS_LANG = zh_CNSYS_CHARSET = gb2312 SYS_DEFAULT_MAXQUOTA = 10000SYS_DEFAULT_MAXALIAS = 10000SYS_DEFAULT_MAXUSERS = 1000SYS_DEFAULT_MAXNDQUOTA = 100SYS_BACKEND_TYPE = ldapSYS_LDAP_BASE = dc=extmail.orgSYS_LDAP_RDN = cn=Manager,dc=extmail.orgSYS_LDAP_PASS = secretSYS_LDAP_HOST = localhostSYS_LDAP_ATTR_USERNAME = mailSYS_LDAP_ATTR_PASSWD = userPassword
mkdir /var/libmkdir /tmp/extman/chown –R vmail:vmail /tmp/extman/chmod 700 /tmp/extman/chmod 600 /usr/local/www/extman/webman.cfcp extmail-0.24-pre8/libs/Ext/CGI.pm /usr/local/www/extman/libs/Ext/cp extmail-0.24-pre8/libs/Ext/Config.pm /usr/local/www/extman/libs/Ext/cp extmail-0.24-pre8/libs/Ext/Lang.pm /usr/local/www/extman/libs/Ext/cp extmail-0.24-pre8/libs/Ext/Session.pm /usr/local/www/extman/libs/Ext/cp extmail-0.24-pre8/libs/Ext/Utils.pm /usr/local/www/extman/libs/Ext/cp extmail-0.24-pre8/libs/Ext/RFC822.pm /usr/local/www/extman/libs/Ext/
cd /usr/ports/net/rrdtool && make install cleancd /usr/ports/devel/p5-File-Tail && make install cleancd /usr/ports/devel/p5-Time-HiRes && make install clean安装mailgraph_ext
cp -Rfp extman-0.16-pre1/addon/mailgraph_ext/ /usr/local/mailgraph_ext/usr/local/mailgraph_ext/mailgraph-init start/usr/local/mailgraph_ext/qmonitor-init start
SYS_CONFIG = /usr/local/www/extmail/ SYS_LANGDIR = /usr/local/www/extmail/lang SYS_TEMPLDIR = /usr/local/www/extmail/htmlSYS_SESS_DIR = /tmp/extmail/ SYS_USER_LANG = zh_CNSYS_USER_CHARSET = gb2312SYS_MFILTER_ON = 1SYS_AUTH_TYPE = ldapSYS_MAILDIR_BASE = /var/domainsSYS_LDAP_BASE = dc=extmail.orgSYS_LDAP_RDN = cn=Manager,dc=extmail.orgSYS_LDAP_PASS = secretSYS_LDAP_HOST = ldap.extmail.orgSYS_LDAP_ATTR_USERNAME = mailSYS_LDAP_ATTR_DOMAIN = virtualDomainSYS_LDAP_ATTR_PASSWD = userPasswordSYS_LDAP_ATTR_QUOTA = mailQuotaSYS_LDAP_ATTR_NDQUOTA = netdiskQuotaSYS_LDAP_ATTR_HOME = homeDirectorySYS_LDAP_ATTR_MAILDIR = mailMessageStore执行如下命令
mkdir /tmp/extmailchown vmail:vmail /tmp/extmail/chmod 700 /tmp/extmail
到目前为止,一个基本的邮件系统已经安装完成,他支持了smtp,pop3,imap,webmail。并且支持对应的SSL加密smtps,pop3s,imaps,https。
telnet localhost 110Trying 127.0.0.1...Connected to localhost.localdomain (127.0.0.1).Escape character is '^]'.+OK Hello there.user test@extmail.org+OK Password required.pass test+OK logged in.list+OK POP3 clients that break here, they violate STD53..quit+OK Bye-bye.Connection closed by foreign host.
通过以下命令获得test@extmail.org的用户名及密码的BASE64编码:
perl -e 'use MIME::Base64; print encode_base64("test\@extmail.org")'dGVzdEBleHRtYWlsLm9yZw==perl -e 'use MIME::Base64; print encode_base64("test")'dGVzdA==然后本机测试,其过程如下
telnet localhost 25Trying 127.0.0.1...Connected to localhost.localdomain (127.0.0.1).Escape character is '^]'.220 mail.extmail.org ESMTP Postfix - by extmail.orgehlo demo.domain.tld250-mail.extmail.org250-PIPELINING250-SIZE 10240000250-VRFY250-ETRN250-AUTH LOGIN PLAIN250-AUTH=LOGIN PLAIN250-ENHANCEDSTATUSCODES250-8BITMIME250 DSNauth login334 VXNlcm5hbWU6dGVzdEBleHRtYWlsLm9yZw==334 UGFzc3dvcmQ6dGVzdA==235 2.0.0 Authentication successfulquit221 2.0.0 Bye最后出现235 Authentication Successful 表明认证成功了。
mail# telnet localhost 25Trying ::1...Trying 127.0.0.1...Connected to localhost.localhostadmin.Escape character is '^]'.220 mail.extmail.org ESMTP Postfixehlo localhost250-mail.extmail.org250-PIPELINING250-SIZE 10240000250-ETRN250-STARTTLS250-AUTH LOGIN PLAIN250-AUTH=LOGIN PLAIN250-ENHANCEDSTATUSCODES250-8BITMIME250 DSNSTARTTLS220 2.0.0 Ready to start TLS^]telnet> qConnection closed.
telnet连接本机的993,995端口出现如下提示:
telnet localhost 993Trying ::1...telnet: connect to address ::1: Connection refusedTrying 127.0.0.1...Connected to localhost.localhostadmin.Escape character is '^]'.^]telnet> qConnection closed.telnet localhost 995Trying ::1...telnet: connect to address ::1: Connection refusedTrying 127.0.0.1...Connected to localhost.localhostadmin.Escape character is '^]'.^]telnet> qConnection closed.也可以在OutLook中如下设置进行测试
http://mail.extmail.orghttps://mail.extmail.org
http://mail.extmail.org/extmanhttps://mail.extmail.org/extman
LDAPMILTERRARARJLHAARCZOOUNZOOLZOPFREEZE
安装过程中会提示安装p5-Mail-SpamAssassin,请选择
AS_ROOTDOMAINKEYSSSLPAZORSPF_QUERYRELAY_COUNTRYTOOLS修改/etc/rc.conf增加如下一行,系统启动时自动运行amavisd
amavisd_enable="YES"
$max_servers = 10;$sa_spam_subject_tag = '[SPAM] ';$mydomain = 'mail.extmail.org';$myhostname = 'mail.extmail.org';@local_domains_maps = qw(.);$sa_tag_level_deflt = undef;$sa_tag2_level_deflt = 5.0;$sa_kill_level_deflt = 5.0;$final_virus_destiny = D_DISCARD;$final_banned_destiny = D_DISCARD;$final_spam_destiny = D_DISCARD;$virus_admin = "postmaster\@$mydomain";$mailfrom_notify_admin = "postmaster\@$mydomain";$mailfrom_notify_recip = "postmaster\@$mydomain";$mailfrom_notify_spamadmin = "postmaster\@$mydomain";@whitelist_sender_maps = read_hash("$MYHOME/white.lst");@blacklist_sender_maps = read_hash("$MYHOME/black.lst");$spam_quarantine_to = "spam\@$mydomain";$virus_quarantine_to = "virus\@$mydomain";$banned_quarantine_to = "spam\@$mydomain";$hdrfrom_notify_admin = "Content Filter执行如下操作";
touch /var/amavis/white.txttouch /var/amavis/black.txtchown –R vscan:vscan /var/amavis/
smtp-amavis unix - - n - 4 smtp -o smtp_data_done_timeout=1200 -o smtp_send_xforward_command=yes -o disable_dns_lookups=yes127.0.0.1:10025 inet n - n - - smtpd -o content_filter= -o local_recipient_maps= -o relay_recipient_maps= -o smtpd_restriction_classes= -o smtpd_helo_restrictions= -o smtpd_sender_restrictions= -o smtpd_recipient_restrictions=permit_mynetworks,reject -o mynetworks=127.0.0.0/8 -o strict_rfc821_envelopes=yes -o smtpd_error_sleep_time=0 -o smtpd_soft_error_limit=1001 -o smtpd_hard_error_limit=1000 -o receive_override_options=修改content_filter ,receive_override_options这两项,禁止地址展开/影射,否则遇到别名时会产生冗余邮件。但是打开这一项receive_override_options后会和邮件列表程序相冲突,导致邮件列表的aliases不能打开。:(所以如果使用了邮件列表,则不要设置receive_override_options这一项。
postconf -e 'content_filter = smtp-amavis:[localhost]:10024'postconf -e 'receive_override_options = no_address_mappings'
clamav_clamd_enable="YES"clamav_freshclam_enable="YES"修改/usr/local/etc/amavisd.conf,增加如下内容,使amavis-new对clamav的支持
['ClamAV-clamd', \&ask_daemon, ["CONTSCAN {}\n", "/var/run/clamav/clamd"], qr/\bOK$/, qr/\bFOUND$/, qr/^.*?: (?!Infected Archive)(.*) FOUND$/ ],
chown –R vscan:vscan /var/run/clamav/chown –R vscan:vscan /var/log/clamav/chown –R vscan:vscan /var/db/clamav/
report_safe 1use_bayes 0auto_learn 0bayes_auto_expire 1skip_rbl_checks 1use_razor2 0use_dcc 0use_pyzor 0dns_available nolock_method flock
#!/bin/shcd /tmp/fetch -q http://www.ccert.edu.cn/spam/sa/Chinese_rules.cfmv Chinese_rules.cf /usr/local/share/spamassassin//usr/local/etc/rc.d/amavisd forcerestart > /dev/null增加执行权限
telnet localhost 25Trying 127.0.0.1...Connected to localhost.localdomain (127.0.0.1).Escape character is '^]'.220 mail.extmail.org ESMTP Postfix - by extmail.orgmail from:maillog中出现如下日至则说明clamav和amavid-new正常工作250 2.1.0 Okrcpt to: 250 2.1.5 Okdata354 End data with .X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*.250 2.0.0 Ok: queued as BC24E85260quit221 2.0.0 ByeConnection closed by foreign host.
Aug 3 15:42:41 mail amavis[730]: (00730-01) Blocked INFECTED (Eicar-Test-Signature), LOCAL [127.0.0.1] [127.0.0.1]
POSTFIXCHINESE
touch /usr/local/mailman/data/aliasestouch /usr/local/mailman/data/virtual-mailmanpostconf -e 'recipient_delimiter=+'postconf -e 'alias_maps=hash:/etc/aliases, hash:/usr/local/mailman/data/aliases'postalias /usr/local/mailman/data/aliasespostconf -e 'virtual_alias_maps = ldap:/usr/local/etc/postfix/ldap_virtual_alias_maps.cf, hash:/usr/local/mailman/data/virtual-mailman'postalias /usr/local/mailman/data/aliasespostmap /usr/local/mailman/data/virtual-mailmanpostconf -e 'default_privs = mailman'postfix reload
cd /usr/local/mailmanbin/genaliaseschown -R vmail:mailman /usr/local/mailman/data/aliases*chown -R vmail:mailman /usr/local/mailman/data/virtual-mailman*chmod 664 /usr/local/mailman/data/aliases*chmod 664 /usr/local/mailman/data/virtual-mailman*cp -Rfp icons/ cgi-bin/iconscp /usr/local/www/icons/powerlogo.gif cgi-bin/icons/修改管理员密码,在这里我默认为123qwe98
MTA = 'Postfix'POSTFIX_STYLE_VIRTUAL_DOMAINS = ['lists.extmail.org']add_virtualhost('lists.extmail.org','lists.extmail.org')DEFAULT_EMAIL_HOST = 'lists.extmail.org'DEFAULT_URL_HOST = 'lists.extmail.org'DEFAULT_SERVER_LANGUAGE = 'zh_CN'
在文件/usr/local/etc/apache22/Includes/extmail.conf中添加如下内容。
<VirtualHost *:80> ServerName lists.extmail.org DocumentRoot /usr/local/mailman/cgi-bin/ ScriptAlias /mailman "/usr/local/mailman/cgi-bin/" Alias /pipermail /usr/local/mailman/archives/public/ <Directory "/usr/local/mailman/archives/public/"> AddDefaultCharset Off </Directory> <Directory "/usr/local/mailman"> Options FollowSymLinks ExecCGI AllowOverride None Order allow,deny Allow from all </Directory&, amp;, gt;</VirtualHost>
http://lists.extmail.org/mailman/admin/mailmanhttp://lists.extmail.org/mailman/listinfo/mailmanhttp://lists.extmail.org/mailman/create更强大的功能在登陆列表的web管理界面后你能看到,比如调整显示界面为中文等等。
如果你的邮件服务器只打算使用pop3功能不打算使用更多,你可以如下这么做:修改/etc/rc.conf,注释掉pop3s,imap,imaps对应的启动选项
courier_imap_pop3d_enable="YES"#courier_imap_imapd_enable="YES"#courier_imap_pop3d_ssl_enable="YES"#courier_imap_imapd_ssl_enable="YES"然后停止正在运行中的pop3s,imap,imaps进程
/usr/local/etc/rc.d/courier-imap-imapd-ssl.sh forcestop/usr/local/etc/rc.d/courier-imap-imapd.sh forcestop/usr/local/etc/rc.d/courier-imap-pop3d-ssl.sh forcestop
修改/usr/local/etc/postfix/master.cf,注释掉对应的smtps选项
#smtps inet n - n - - smtpd# -o smtpd_tls_wrappermode=yes# -o smtpd_sasl_auth_enable=yes# -o smtpd_client_restrictions=permit_sasl_authenticated,reject然后重新加载以下postfix
有时候为了安全,我们可能只能使用https,那么在用户连http://mail.extmail.org的时候,就要自动重定向到https://mail.extmail.org 做起来很简单,修改我们„虚拟主机配置文件(extmail.conf),在虚拟主机配置内添加如下一条指令即可
启动postfix
postqueue –pmailqpostqueue –p |tail修复队列以及任何权限错误
通过此文档,读者应该能够较容易地架设一个功能较齐全的电子邮件系统。当使用一段时间后,用户将发现这个系统还有很多比较粗糙的地方,不尽人意。日后,本文档将继续保持更新,逐步将一些高级的设置方法公布出来,争取ExtMail Solution更加完整,力求完美。
自由广告区 |
分类导航 |
邮件新闻资讯: IT业界 | 邮件服务器 | 邮件趣闻 | 移动电邮 电子邮箱 | 反垃圾邮件|邮件客户端|网络安全 行业数据 | 邮件人物 | 网站公告 | 行业法规 网络技术: 邮件原理 | 网络协议 | 网络管理 | 传输介质 线路接入 | 路由接口 | 邮件存储 | 华为3Com CISCO技术 | 网络与服务器硬件 操作系统: Windows 9X | Linux&Uinx | Windows NT Windows Vista | FreeBSD | 其它操作系统 邮件服务器: 程序与开发 | Exchange | Qmail | Postfix Sendmail | MDaemon | Domino | Foxmail KerioMail | JavaMail | Winwebmail |James Merak&VisNetic | CMailServer | WinMail 金笛邮件系统 | 其它 | 反垃圾邮件: 综述| 客户端反垃圾邮件|服务器端反垃圾邮件 邮件客户端软件: Outlook | Foxmail | DreamMail| KooMail The bat | 雷鸟 | Eudora |Becky! |Pegasus IncrediMail |其它 电子邮箱: 个人邮箱 | 企业邮箱 |Gmail 移动电子邮件:服务器 | 客户端 | 技术前沿 邮件网络安全: 软件漏洞 | 安全知识 | 病毒公告 |防火墙 攻防技术 | 病毒查杀| ISA | 数字签名 邮件营销: Email营销 | 网络营销 | 营销技巧 |营销案例 邮件人才:招聘 | 职场 | 培训 | 指南 | 职场 解决方案: 邮件系统|反垃圾邮件 |安全 |移动电邮 |招标 产品评测: 邮件系统 |反垃圾邮件 |邮箱 |安全 |客户端 |