Linux配置postfix+Extmail并具有防垃圾邮件防病毒功能(二)

八、安装postfix

1.添加用户和组

groupadd postfix
useradd -g postfix postfix
groupadd postdrop
useradd -g postdrop postdrop

2.安装并配置:

tar -zxvf postfix-2.7.2-RC2.tar.gz
cd postfix-2.7.2-RC2
make makefiles 'CCARGS=-DHAS_MYSQL -I/usr/local/mysql/include/mysql -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/local/sasl2/include/sasl -I/usr/local/BerkeleyDB/include  -DUSE_TLS -I/usr/local/ssl/include/openssl ' 'AUXLIBS=-L/usr/local/mysql/lib/mysql -lmysqlclient -lz -lm -L/usr/local/sasl2/lib -lsasl2 -L/usr/local/BerkeleyDB/lib -L/usr/local/ssl/lib -lssl -lcrypto'
make
make install

 

make install后会出现提示进行安装,可以一路回车,也可以按提示并根据自己的需要进行配置,我这里的显示如下 :

Please specify the prefix for installed file names. Specify this ONLY

if you are building ready-to-install packages for distribution to other

machines.

install_root: [/] /

Please specify a directory for scratch files while installing Postfix. You

must have write permission in this directory.

tempdir: [/root/postfix_soft/postfix-2.7.2-RC2] /tmp

Please specify the final destination directory for installed Postfix

configuration files.

config_directory: [/etc/postfix]

Please specify the final destination directory for installed Postfix

administrative commands. This directory should be in the command search

path of adminstrative users.

command_directory: [/usr/sbin]

Please specify the final destination directory for installed Postfix

daemon programs. This directory should not be in the command search path

of any users.

daemon_directory: [/usr/libexec/postfix]

Please specify the final destination directory for Postfix-writable

data files such as caches or random numbers. This directory should not

be shared with non-Postfix software.

data_directory: [/var/lib/postfix]

Please specify the destination directory for the Postfix HTML

files. Specify “no” if you do not want to install these files.

html_directory: [no]

Please specify the owner of the Postfix queue. Specify an account with

numerical user ID and group ID values that are not used by any other

accounts on the system.

mail_owner: [postfix]

Please specify the final destination pathname for the installed Postfix

mailq command. This is the Sendmail-compatible mail queue listing command.

mailq_path: [/usr/bin/mailq]

Please specify the destination directory for the Postfix on-line manual

pages. You can no longer specify “no” here.

manpage_directory: [/usr/local/man]

Please specify the final destination pathname for the installed Postfix

newaliases command. This is the Sendmail-compatible command to build

alias databases for the Postfix local delivery agent.

newaliases_path: [/usr/bin/newaliases]

Please specify the final destination directory for Postfix queues.

queue_directory: [/var/spool/postfix]

Please specify the destination directory for the Postfix README

files. Specify “no” if you do not want to install these files.

readme_directory: [no]

Please specify the final destination pathname for the installed Postfix

sendmail command. This is the Sendmail-compatible mail posting interface.

sendmail_path: [/usr/sbin/sendmail]

Please specify the group for mail submission and for queue management

commands. Specify a group name with a numerical group ID that is

not shared with other accounts, not even with the Postfix mail_owner

account. You can no longer specify “no” here.

setgid_group: [postdrop]

注:如果出现bin/postconf: error while loading shared libraries: libmysqlclient.so.16: cannot open shared object file: No such file or directory 的错误,解决方法如下:

ln -s /usr/local/mysql/lib/mysql/libmysqlclient.so.16 /usr/lib/libmysqlclient.so.16

3.生成二进制文件

newaliases

4.修改postfix的main.cf文件

vim /etc/postfix/main.cf 找到以下几项进行修改

myhostname = mail.lsanotes.cn
myorigin = lsanotes.cn
mydomain = lsanotes.cn
mydestination =
mynetworks = 192.168.10.0/24, 127.0.0.0/8 

并在该文件的最后添加:

broken_sasl_auth_clients = yes
smtpd_recipient_restrictions=permit_mynetworks,permit_sasl_authenticated,reject_invalid_hostname,reject_non_fqdn_hostname,reject_unknown_sender_domain,reject_non_fqdn_sender,reject_non_fqdn_recipient,reject_unknown_recipient_domain,reject_unauth_pipelining,reject_unauth_destination
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_security_options = noanonymous
smtpd_sasl_application_name = smtpd
smtpd_banner = Welcome to our $myhostname ESMTP,Warning: Version not Available!
virtual_mailbox_base = /usr/mailbox
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
virtual_alias_domains =
virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
virtual_uid_maps = static:105
virtual_gid_maps = static:113
virtual_transport = virtual
maildrop_destination_recipient_limit = 1
maildrop_destination_concurrency_limit = 1
message_size_limit = 14336000
|virtual_mailbox_limit = 20971520
virtual_create_maildirsize = yes
virtual_mailbox_extended = yes
virtual_mailbox_limit_maps = mysql:/etc/postfix/mysql_virtual_mailbox_limit_maps.cf
virtual_mailbox_limit_override = yes
virtual_maildir_limit_message = Sorry, the user's maildir has overdrawn his diskspace quota,please Tidy your mailbox and try again later.
virtual_overquota_bounce = yes

5.在/etc/postfix下建立虚拟域和虚拟用户相关的配置文件

vim mysql_virtual_alias_maps.cf

user = extmail
password = extmail
hosts = localhost
dbname = extmail
table = alias
select_field = goto
where_field = address

vim mysql_virtual_limit_maps.cf

user = extmail
password = extmailisi
hosts = localhost
dbname = extmail
table = mailbox
select_field = quota
where_field = username

vim mysql_virtual_mailbox_maps.cf

user = extmail
password = extmailisi
hosts = localhost
dbname = extmail
table = mailbox
select_field = maildir
where_field = username

vim  mysql_virtual_domains_maps.cf

user = extmail
password = extmailisi
hosts = localhost
dbname = extmail
table = domain
select_field = description
where_field = domain

Post a Comment