服务器维护,服务器代维,安全设置,漏洞扫描,入侵检测服务

dirtysea 发表于 2010-7-23 18:03:57

利用ubuntu extmail 30分钟配置好一个功能强大的邮件服务器

<P>利用ubuntu extmail 30分钟配置好一个功能强大的邮件服务器V1.1,以下文档通过19个大的步骤进行配置,配置成功! </P>
<P>&nbsp;</P>
<P>&nbsp;</P>
<P>由于网上ubuntu extmail的步骤特别多,看了都头痛,在此特别给朋友们**了一个简洁的安装文档,希望大家喜欢:) </P>
<P>环境: <BR>ubuntu&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8.04 TLS <BR>postfix&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2.5.1 <BR>extmail&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.2 <BR>extman&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.1 </P>
<P>&nbsp;</P>
<P>&nbsp;</P>
<P>1.安装依赖包 <BR>apt-get install mysql-client-5.0 mysql-server apache2 postfix postfix-mysql postfix-doc courier-authdaemon courier-authlib-mysql courier-pop courier-pop-ssl courier-imap courier-imap-ssl libsasl2-modules libsasl2-modules-sql sasl2-bin libpam-mysql openssl libapache2-mod-fastcgi libfcgi-perl build-essential libtool libnet-server-perl libnet-cidr-perl libberkeleydb-perl arc zoo lzop liblzo1 libstdc++5 libgd-gd2-perl libfile-tail-perl libdigest-sha1-perl libdigest-HMAC-perl libnet-ip-perl libnet-dns-perl libhtml-tagset-perl libhtml-parser-perl libio-stringy-perl libio-multiplex-perl libio-socket-ssl-perl libio-zlib-perl libnet-ssleay-perl libunix-syslog-perl libtimedate-perl libmailtools-perl libconvert-binhex-perl libconvert-tnef-perl libconvert-uulib-perl libcompress-zlib-perl libarchive-zip-perl libarchive-tar-perl perl-suid </P>
<P>&nbsp;</P>
<P>&nbsp;</P>
<P>你会被询问以下问题: <BR>Create directories for web-based administration? &lt;– No <BR>General type of mail configuration: &lt;– Internet Site <BR>System mail name: &lt;– mail.extmail.org </P>
<P>&nbsp;</P>
<P>&nbsp;</P>
<P>2.下载extmail-1.2和extman-1.1,并修改配置 <BR>下载地址:<A href="http://www.extmail.org/download"><FONT color=#006666>http://www.extmail.org/download</FONT></A> <BR>tar xvzf extmail-1.2.tar.gz <BR>tar xvzf extman-1.1.tar.gz <BR>mkdir /var/www/extsuite <BR>mv extmail-1.2/ /var/www/extsuite/extmail <BR>mv extman-1.1/ /var/www/extsuite/extman <BR>cp /var/www/extsuite/extman/docs/mysql_virtual_*.cf /etc/postfix/ </P>
<P>注意,非常重要:修改/etc/postfix/mysql_virtual_*.cf,将其中的“localhost”均改为“127.0.0.1”,修改数据库配置,保证能够连到mysql </P>
<P>&nbsp;</P>
<P>&nbsp;</P>
<P>3.建立相关系统用户 <BR>1)新建普通用户 <BR>useradd -m -d /home/hugwww -s /bin/bash hugwww <BR>passwd hugwww </P>
<P>2)删除以前gid,uid为1000的用户 <BR>userdel -r gaojinbo </P>
<P>3)建立extmail所需要的用户和组 <BR>groupadd -g 1000 vgroup <BR>useradd -m -g vgroup -u 1000 -d /home/vmail -s /bin/false vuser </P>
<P>&nbsp;</P>
<P>&nbsp;</P>
<P>4.修改权限 <BR>chmod 755 /etc/postfix/mysql_virtual_*.cf <BR>chgrp postfix /etc/postfix/mysql_virtual_*.cf <BR>chown -R vuser:vgroup /var/www/extsuite/extmail/cgi/ <BR>chown -R vuser:vgroup /var/www/extsuite/extman/cgi/ <BR>cd /var/www/extsuite/extmail/ <BR>cp webmail.cf.default webmail.cf <BR>cd /var/www/extsuite/extman/ <BR>cp webman.cf.default webman.cf </P>
<P>&nbsp;</P>
<P>&nbsp;</P>
<P>5.修改/var/www/extsuite/extmail/webmail.cf里的其他参数,主要变动的内容见下: <BR>vi /var/www/extsuite/extmail/webmail.cf </P>
<P>SYS_USER_LANG = zh_CN <BR>SYS_MYSQL_USER = extmail <BR>SYS_MYSQL_PASS = extmail <BR>SYS_MYSQL_DB = extmail <BR>SYS_MYSQL_SOCKET = /var/run/mysqld/mysqld.sock <BR>SYS_AUTHLIB_SOCKET = /var/run/courier/authdaemon/socket <BR>SYS_MAILDIR_BASE = /home/vmail <BR>SYS_MESSAGE_SIZE_LIMIT = 102400000 //注:这个选项为修改附件的大小,默认为5M,你可以自行修改,这里面改了是不行的,还要去postfix里面修改,我在下面会讲到 </P>
<P>&nbsp;</P>
<P>&nbsp;</P>
<P>6.修改 /var/www/extsuite/extman/webman.cf的参数 <BR>vi /var/www/extsuite/extman/webman.cf </P>
<P>SYS_CAPTCHA_ON = 0 //用于关闭后台登录时的验证码 <BR>SYS_MAILDIR_BASE = /home/vmail <BR>SYS_MYSQL_SOCKET = /var/run/mysqld/mysqld.sock <BR>SYS_LANG = zh_CN <BR>SYS_GROUPMAIL_SENDER = postmaster@extmail.org //注: 这个选项是,你在后台群发后,用户收到邮件的发件人地址,你可以自行修改 </P>
<P>&nbsp;</P>
<P>&nbsp;</P>
<P>7.修改/var/www/extsuite/extman/contrib/passwd2ext.pl </P>
<P>my $sock = ‘/var/run/mysqld/mysqld.sock’; </P>
<P>&nbsp;</P>
<P>&nbsp;</P>
<P>8.数据库初始化 <BR>执行以下命令导入mysql数据库结构及初始化数据,注意必须逐行输入以下命令. <BR>请把gaojinbo.com替换成自己的密码 </P>
<P>mysql -u root -pgaojinbo.com &lt; /var/www/extsuite/extman/docs/extmail.sql <BR>mysql -u root -pgaojinbo.com &lt; /var/www/extsuite/extman/docs/init.sql </P>
<P>&nbsp;</P>
<P>&nbsp;</P>
<P>9.建立临时文件夹: <BR>mkdir /tmp/extman <BR>chown -R vuser:vgroup /tmp/extman </P>
<P>编辑rc.local,加入下面内容以实现开机自动建立编辑rc.local,加入下面内容以实现开机自动建立 <BR>vi&nbsp; /etc/rc.local </P>
<P>if [ ! -d /tmp/extman ]; then <BR>mkdir /tmp/extman <BR>chown -R vuser:vgroup /tmp/extman <BR>fi </P>
<P>&nbsp;</P>
<P>&nbsp;</P>
<P>10.建立上边导入mysql的postmaster@extmail.org帐户的Maildir,请输入如下命令: <BR>cd /var/www/extsuite/extman/tools <BR>./maildirmake.pl /home/vmail/extmail.org/postmaster/Maildir <BR>chown -R vuser:vgroup /home/vmail/extmail.org/ </P>
<P>&nbsp;</P>
<P>&nbsp;</P>
<P>11.Postfix配置 <BR>cd /etc/postfix/ <BR>cp main.cf main.cf_backup </P>
<P>vi main.cf <BR># TLS parameters <BR>smtpd_tls_cert_file = /etc/postfix/smtpd.cert <BR>smtpd_tls_key_file = /etc/postfix/smtpd.key <BR>smtpd_use_tls = yes <BR># See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for <BR># information on enabling SSL in the smtp client. <BR>mydomain = extmail.org <BR>myhostname = mail.$mydomain <BR>myorigin = $mydomain <BR>mydestination = mail.$mydomain, localhost.$mydomain, localhost <BR>alias_maps = hash:/etc/aliases <BR>alias_database = hash:/etc/aliases <BR>relayhost = <BR>mynetworks = 127.0.0.1 <BR>message_size_limit = 102400000 <BR>mailbox_size_limit = 0 <BR>recipient_delimiter = + <BR>inet_interfaces = all <BR>html_directory = /usr/share/doc/postfix/html <BR>######### virtual config############ <BR>virtual_alias_domains = <BR>virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf <BR>virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf <BR>virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf <BR>virtual_mailbox_limit_maps = mysql:/etc/postfix/mysql_virtual_limit_maps.cf <BR>virtual_mailbox_base = /home/vmail <BR>virtual_uid_maps = static:1000 <BR>virtual_gid_maps = static:1000 <BR>virtual_create_maildirsize = yes <BR>virtual_mailbox_extended = yes <BR>virtual_overquota_bounce = yes <BR>virtual_mailbox_limit_override = yes <BR>virtual_maildir_limit_message = Sorry, the your Maildir has overdrawn your diskspace quota, please free up some of spaces of your mailbox try again. <BR>proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks $virtual_mailbox_limit_maps </P>
<P>重启 postfix <BR>/etc/init.d/postfix restart </P>
<P>&nbsp;</P>
<P>&nbsp;</P>
<P>12.SMTP身份认证 <BR>cd /etc/postfix <BR>openssl req -new -outform PEM -out smtpd.cert -newkey rsa:2048 -nodes -keyout smtpd.key -keyform PEM -days 365 -x509 </P>
<P>它们询问你问题 <BR>Country Name (2 letter code) : //国家 <BR>State or Province Name (full name) : //省 <BR>Locality Name (eg, city) []: //城市 <BR>Organization Name (eg, company) : //组织名称 <BR>Organizational Unit Name (eg, section) []: 组织单位名称 <BR>Common Name (eg, YOUR name) []: 通用名称 <BR>Email Address []: 邮件地址 </P>
<P>&nbsp;</P>
<P>&nbsp;</P>
<P>13.Apache2配置: <BR>vi&nbsp; /etc/apache2/sites-enabled/mail <BR>&lt;VirtualHost *&gt; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ServerAdmin admin@gaojinbo.com <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ServerName mail.gaojinbo.com <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DocumentRoot /var/www/extsuite/extmail/html <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Alias /extmail/cgi/ /var/www/extsuite/extmail/dispatch.fcgi/ <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Alias /extmail /var/www/extsuite/extmail/html <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Ifmodule mod_fastcgi.c&gt; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FastCgiExternalServer /var/www/extsuite/extmail/dispatch.fcgi -host 127.0.0.1:8888 -idle-timeout 240 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/Ifmodule&gt; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Location "/extmail/cgi"&gt; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SetHandler fastcgi-script <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/Location&gt; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ScriptAlias /extman/cgi/ /var/www/extsuite/extman/cgi/ <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Alias /extman /var/www/extsuite/extman/html <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ErrorLog /var/log/apache2/error.log <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Possible values include: debug, info, notice, warn, error, crit, <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # alert, emerg. <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogLevel warn <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CustomLog /var/log/apache2/access.log combined <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SuexecUserGroup vuser vgroup <BR>&lt;/VirtualHost&gt; </P>
<P>&nbsp;</P>
<P>&nbsp;</P>
<P>14.编辑/var/www/extsuite/extmail/dispatch-init文件: <BR>vi&nbsp; /var/www/extsuite/extmail/dispatch-init <BR>MAXFORK=10 <BR>最后启动fastcgi server: <BR>/var/www/extsuite/extmail/dispatch-init start <BR>如果没有意外将启动10个dispatch.fcgi守护进程,可以通过以下命令将启动命令加到rc.local中,实现自启动: <BR>echo "/var/www/extsuite/extmail/dispatch-init start"&gt;&gt;/etc/rc.local </P>
<P>&nbsp;</P>
<P>&nbsp;</P>
<P>15.SMTP认证 <BR>1).更改saslauthd <BR>vi /etc/default/saslauthd <BR>更改如下几项 <BR>START=yes&nbsp;&nbsp;&nbsp; //设置开机自动启动 <BR>OPTIONS="-c -m /var/spool/postfix/var/run/saslauthd -r" </P>
<P>2). 创建文件/etc/pam.d/smtp <BR>vi /etc/pam.d/smtp <BR>内容如下: <BR>auth&nbsp;&nbsp;&nbsp; required&nbsp;&nbsp; pam_mysql.so user=extmail passwd=extmail host=127.0.0.1 db=extmail table=mailbox usercolumn=username passwdcolumn=password crypt=1 <BR>account sufficient pam_mysql.so user=extmail passwd=extmail host=127.0.0.1 db=extmail table=mailbox usercolumn=username passwdcolumn=password crypt=1 <BR>解释一下:其实就是定义一个查询的方式 crypt=1或者0表示加密或者不加密&nbsp; 注意对照你的数据库 还有用户名密码 请保持跟自己的一致 </P>
<P>3).由于postfix处于chroot,要想调用到saslauthd 必须更改socket文件 <BR>mkdir -p /var/spool/postfix/var/run/saslauthd <BR>vi /etc/postfix/sasl/smtpd.conf </P>
<P>创建smtpd.conf,并且内容如下: <BR>pwcheck_method:saslauthd <BR>mech_list:plain login <BR>allow_plaintext: true <BR>auxprop_plugin: mysql <BR>sql_hostnames: 127.0.0.1 <BR>sql_user: extmail <BR>sql_password: extmail <BR>sql_database: extmail <BR>log_level:7 <BR>sql_select: SELECT password FROM mailbox WHERE username=’%u@%r’ and domain=’%r’</P>
<P>4).更改main.cf 文件 <BR>vi&nbsp; /etc/postfix/main.cf <BR>###########SMTP AUTH config############### <BR>broken_sasl_auth_clients = yes <BR>smtpd_sasl_auth_enable = yes <BR>smtpd_sasl_local_domain = $myhostname <BR>smtpd_sasl_security_options = noanonymous <BR>###########smtpd related config############ <BR>smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_sender_login_mismatch, reject_unknown_sender_domain, reject_non_fqdn_hostname, reject_non_fqdn_sender, reject_non_fqdn_recipient, reject_unknown_recipient_domain, reject_unauth_destination, reject_unauth_pipelining, reject_invalid_hostname, check_recipient_maps </P>
<P>5).添加用户 <BR>adduser postfix sasl </P>
<P>6).重启postfix saslauthd <BR>/etc/init.d/postfix restart <BR>/etc/init.d/saslauthd restart </P>
<P>7).测验 <BR>telnet localhost 25 <BR>Trying 127.0.0.1… <BR>Connected to localhost. <BR>Escape character is ‘^]’. <BR>220 mail.extmail.org ESMTP Postfix <BR>ehlo localhost <BR>250-mail.extmail.org <BR>250-PIPELINING <BR>250-SIZE 102400000 <BR>250-VRFY <BR>250-ETRN <BR>250-STARTTLS <BR>250-AUTH PLAIN LOGIN <BR>250-AUTH=PLAIN LOGIN <BR>250-ENHANCEDSTATUSCODES <BR>250-8BITMIME <BR>250 DSN <BR>auth login <BR>334 VXNlcm5hbWU6 <BR>cG9zdG1hc3RlckBleHRtYWlsLm9yZw== <BR>334 UGFzc3dvcmQ6 <BR>ZXh0bWFpbA== <BR>235 2.7.0 Authentication successful <BR>quit <BR>221 2.0.0 Bye <BR>Connection closed by foreign host. <BR>如果出现Authentication successful 表示没有问题了 </P>
<P>&nbsp;</P>
<P>&nbsp;</P>
<P>16.POP验证 <BR>vi /etc/courier/authdaemonrc <BR>#更改如下一项 <BR>authmodulelist="authmysql" </P>
<P>cp /etc/courier/authmysqlrc /etc/courier/authmysqlrc_orig <BR>cat /dev/null &gt; /etc/courier/authmysqlrc </P>
<P>vi /etc/courier/authmysqlrc <BR>#内容如下: <BR>MYSQL_SERVER&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; localhost <BR>MYSQL_USERNAME&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; extmail <BR>MYSQL_PASSWORD&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; extmail <BR>MYSQL_SOCKET&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /var/run/mysqld/mysqld.sock <BR>MYSQL_PORT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3306 <BR>MYSQL_OPT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0 <BR>MYSQL_DATABASE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; extmail <BR>MYSQL_USER_TABLE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mailbox <BR>MYSQL_CRYPT_PWFIELD&nbsp;&nbsp;&nbsp;&nbsp; password <BR>MYSQL_UID_FIELD&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; uidnumber <BR>MYSQL_GID_FIELD&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gidnumber <BR>MYSQL_LOGIN_FIELD&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; username <BR>MYSQL_HOME_FIELD&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; homedir <BR>MYSQL_NAME_FIELD&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; name <BR>MYSQL_MAILDIR_FIELD&nbsp;&nbsp;&nbsp;&nbsp; maildir <BR>MYSQL_QUOTA_FIELD&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; quota <BR>MYSQL_SELECT_CLAUSE&nbsp;&nbsp;&nbsp;&nbsp; SELECT username,password,"",uidnumber,gidnumber,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&nbsp;&nbsp; \ <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FROM mailbox&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \ <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WHERE username = ‘$(local_part)@$(domain)’ </P>
<P>配置Courier-POP3 <BR>vi /etc/courier/pop3d <BR>MAILDIRPATH=/home/vmail/ </P>
<P>配置Courier-IMAP <BR>vi /etc/courier/imapd <BR>MAILDIRPATH=/home/vmail/ </P>
<P>重新启动 <BR>/etc/init.d/courier-authdaemon restart <BR>/etc/init.d/courier-imap restart <BR>/etc/init.d/courier-imap-ssl restart <BR>/etc/init.d/courier-pop restart <BR>/etc/init.d/courier-pop-ssl restart </P>
<P>测试Courier- Authlib是否能成功连接mysql <BR>authtest -s login postmaster@extmail.org extmail <BR>如果成功应该有如下显示 <BR>Authentication succeeded. <BR>&nbsp;&nbsp;&nbsp;&nbsp; Authenticated: postmaster@extmail.org&nbsp; (uid 1000, gid 1000) <BR>&nbsp;&nbsp;&nbsp; Home Directory: /home/vmail/extmail.org/postmaster <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Maildir: /home/vmail/extmail.org/postmaster/Maildir/ <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Quota: 104857600S <BR>Encrypted Password: $1$phz1mRrj$3ok6BjeaoJYWDBsEPZb5C0 <BR>Cleartext Password: extmail <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Options: disablesmtpd=0,disablesmtp=0,disablewebmail=0,disablenetdisk=0,</P>
<P>disableimap=0,disablepop3=0,netdiskquota=52428800S </P>
<P>&nbsp;</P>
<P>测试pop3 <BR>telnet localhost 110 <BR>Trying 127.0.0.1… <BR>Connected to localhost.localdomain (127.0.0.1). <BR>Escape character is ‘^]’. <BR>+OK Hello there. <BR>user postmaster@extmail.org <BR>+OK Password required. <BR>pass extmail <BR>+OK logged in. <BR>list <BR>+OK POP3 clients that break here, they violate STD53. <BR>. <BR>quit <BR>+OK Bye-bye. <BR>Connection closed by foreign host. <BR>如果出现问题请仔细分析日志 </P>
<P>&nbsp;</P>
<P>&nbsp;</P>
<P>17.图形日志extmail <BR>apt-get install mailgraph <BR>cp -r /var/www/extsuite/extman/addon/mailgraph_ext/ /usr/local/mailgraph_ext </P>
<P>vi /usr/local/mailgraph_ext/mailgraph-init为: <BR>MAIL_LOG=/var/log/mail.log <BR>然后复制文件 <BR>cp /var/www/extsuite/extman/addon/mailgraph_ext/mailgraph-init /etc/init.d/mailgraph <BR>cp /var/www/extsuite/extman/addon/mailgraph_ext/qmonitor.pl /etc/init.d/qmonitor </P>
<P>启动服务 <BR>/etc/init.d/mailgraph start </P>
<P>&nbsp;</P>
<P>&nbsp;</P>
<P>18.安装Maildrop <BR>apt-get install maildrop <BR>vi /etc/maildropmysql.config&nbsp;&nbsp;&nbsp;&nbsp; //创建一个文件 <BR>hostname localhost <BR>port 3306 <BR>database extmail <BR>dbuser extmail <BR>dbpw extmail #修改为您的密码 <BR>dbtable mailbox <BR>default_uidnumber 1000 <BR>default_gidnumber 1000 <BR>uidnumber_field uidnumber <BR>gidnumber_field gidnumber <BR>uid_field username <BR>homedirectory_field concat(‘/home/vmail/’,homedir,’/’) <BR>maildir_field concat(‘/home/vmail/’,maildir) <BR>quota_field quota <BR>mailstatus_field active </P>
<P>修改/etc/maildroprc <BR>vi /etc/maildroprc <BR>logfile "/var/log/maildrop.log" </P>
<P>手动创建日志 <BR>vi /var/log/maildrop.log <BR>chown vuser:vgroup /var/log/maildrop.log <BR>chmod 766 /var/log/maildrop.log </P>
<P>vi /etc/logrotate.d/maildrop <BR>内容为下面: <BR>/var/log/maildrop.log { <BR>daily <BR>notifempty <BR>missingok <BR>rotate 5 <BR>compress <BR>create 766 vuser vgroup <BR>sharedscripts <BR>} </P>
<P>vi /etc/postfix/master.cf,注释掉原来maildrop的配置内容并改为: <BR>maildrop&nbsp;&nbsp; unix&nbsp; -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pipe <BR>&nbsp;&nbsp; flags=DRhu&nbsp; user=vmail argv=maildrop -w 90 -d ${user}@${nexthop} ${recipient} ${user}&nbsp; ${extension} {nexthop} </P>
<P>由于maildrop不支持一次接收多个收件人,因此必须在/etc/postfix/main.cf增加如下参数: <BR>vi /etc/postfix/main.cf <BR>###### Maildrop config ######## <BR>maildrop_destination_recipient_limit = 1 <BR>virtual_transport = maildrop: </P>
<P>创建vi /etc/quotawarnmsg,为邮箱空间超过配额时的警告邮件内容 <BR>X-Comment: Rename/Copy this file to quotawarnmsg, and make appropriate changes <BR>X-Comment: See deliverquota man page for more information <BR>From: Mail Delivery System &lt;Mailer-Daemon@example.com&gt; <BR>Reply-To: support@example.com <BR>To: Valued Customer:; <BR>Subject: Mail quota warning <BR>Mime-Version: 1.0 <BR>Content-Type: text/plain; charset=iso-8859-1 <BR>Content-Transfer-Encoding: 7bit <BR>Your mailbox on the server is now more than 90% full. So that you can continue <BR>to receive mail you need to remove some messages from your mailbox. </P>
<P>&nbsp;</P>
<P>&nbsp;</P>
<P>19.解决extman问题 <BR>1)修改相关服务路径 <BR>vi /var/www/extsuite/extman/daemon/cmd_plugin/linux-cmd </P>
<P>2)启动服务 <BR>/var/www/extsuite/extman/daemon/cmdserver -v -d </P>
<P>3)写入rc.local开机自动运行 <BR>echo "/var/www/extsuite/extman/daemon/cmdserver -v -d" &gt;&gt;/etc/rc.local </P>
<P>至此,全部完成 登录 <A href="http://mail.gaojinbo.com/extmail/"><FONT color=#006666>http://mail.gaojinbo.com/extmail/</FONT></A> 前台,<A href="http://mail.gaojinbo.com/extman/后台"><FONT color=#006666>http://mail.gaojinbo.com/extman/后台</FONT></A> <BR>后台默认用户名 root@extmail.org 默认密码 extmail*123*,登录前台需要自己先添加一个用户 </P>
<P>&nbsp;</P>
<P>防病毒,过滤配置档待续。。。 </P>
页: [1]
查看完整版本: 利用ubuntu extmail 30分钟配置好一个功能强大的邮件服务器