1. 安装postfix tar -zxf postfix-2.4.6.tar.gz cd postfix-2.4.6 mv /usr/sbin/sendmail /usr/sbin/sendmail.OFF mv /usr/bin/newaliases /usr/bin/newaliases.OFF mv /usr/bin/mailq /usr/bin/mailq.OFF chmod 755 /usr/sbin/sendmail.OFF /usr/bin/newaliases.OFF /usr/bin/mailq.OFF vi /etc/passwd: postfix:*:12345:12345:postfix:/no/where:/no/shell vi /etc/group: postfix:*:12345: 或者用命令 groupadd postfix -c 12345 useradd -u 12345 -g 12345 -c postfix -d/dev/null -s/bin/false postfix groupadd -c 54321 postdrop 开始安装 make make install 一路enter直到安装完成
2.安装 vm-pop3d (为了收邮件) tar zxvf vm-pop3d-1.1.6.tar.gz cd vm-pop3d-1.1.6 ./configure --prefix=/usr/local/pop3 --enable-pam --enable-virtual --enable-ip-based-virtual make make install
vi /etc/xinetd.d/pop3 # default: off # description: The rsync server is a good addition to an ftp server, as it \ # allows crc checksumming etc. service pop3 { disable = no socket_type = stream wait = no protocol = tcp user = root server = /usr/local/pop3/sbin/vm-pop3d } 然后就service xinetd start 启动pop3 3.配置安装完的postfix配置目录在/etc/postfix下,主要配置main.cf,粗体部分是我修改过的,mail.lzz.com配hosts vi /etc/postfix/main.cf queue_directory = /var/spool/postfix command_directory = /usr/sbin daemon_directory = /usr/libexec/postfix mail_owner = postfix myhostname = mail.lzz.com inet_interfaces = all mydestination = $myhostname unknown_local_recipient_reject_code = 550 mynetworks = 192.168.0.0/16, 127.0.0.0/8, 0.0.0.0/0 alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases local_recipient_maps = $alias_maps unix:passwd.byname debug_peer_level = 2 debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin xxgdb $daemon_directory/$process_name $process_id & sleep 5 sendmail_path = /usr/sbin/sendmail newaliases_path = /usr/bin/newaliases mailq_path = /usr/bin/mailq setgid_group = postdrop html_directory = no manpage_directory = /usr/local/man sample_directory = /etc/postfix readme_directory = no 启动postfix: postfix start 注意iptables要开放25和110端口,hosts.allow加入vm-pop3d:all 此时应该就可以用foxmail收发邮件了,我测试的时候一直提示输入密码,输入系统密码又不对看日志cat /var/log/maillog Dec 3 09:18:08 zhangwenhao1 vm-pop3d[12632]: Couldn't open password file: /etc/virtual/mail.lzz.com/passwd 之后 mkdir -p /etc/virtual/mail.lzz.com/ ln -s /etc/shadow /etc/virtual/mail.lzz.com/passwd 再次测试,发送接收邮件成功,这里是使用系统的帐户,也可以自己新建虚拟账户,利用apache的htpasswd /usr/local/apache2/bin/htpasswd -c /etc/virtual/mail.lzz.com/passwd lzz 输入密码,就可以使用虚拟帐户收发邮件了