Subscribe to RSS Feed ログイン

CentOS設定メモ

CentOS5.4でPostfix+MySQL+PostfixAdmin

CentOS5.4環境でPostfix+MySQL+PostfixAdminを設定した時のメモ

※yumでインストールできるpostfixはMySQL対応していないようなのでソースを取得


[root@localhost]# rpm -ivh http://ftp.riken.jp/Linux/centos/5.5/centosplus/SRPMS/postfix-2.3.3-2.el5.centos.mysql_pgsql.src.rpm
[root@localhost]# cd /usr/src/redhat/SPECS/
[root@localhost]# vi postfix.spec
MYSQL = 1
PGSQL = 0

※必要であれば
[root@localhost]# yum -y install gcc rpm-build db4-devel pkgconfig zlib-devel openldap-devel cyrus-sasl-devel pcre-devel mysql-devel openssl-devel

[root@localhost]# rpmbuild -ba postfix.spec
[root@localhost]# rpm -Uhv /usr/src/redhat/RPMS/i386/postfix-2.3.3-2.el5.centos.mysql_pgsql.i386.rpm

[root@localhost]# cd /usr/local/src
※PostfixAdminのソースを取得
[root@localhost]# wget http://downloads.sourceforge.net/project/postfixadmin/postfixadmin/postfixadmin-2.3.2/postfixadmin-2.3.2.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fpostfixadmin%2Ffiles%2Fpostfixadmin%2Fpostfixadmin-2.3.2%2F&ts=1296602972&use_mirror=jaist
[root@localhost]# tar xzvf postfixadmin-2.3.2.tar.gz
[root@localhost]# mv postfixadmin-2.3.2 /var/www/html/postfixadmin

[root@localhost]# cd /var/www/html/postfixadmin
[root@localhost]# vi config.inc.php

[root@localhost]# cd /var/www/postfixadmin
[root@localhost]# vi config.inc.php
//$CONF['configured'] = false;
$CONF['configured'] = true;

//$CONF['default_language'] = ‘en’;
$CONF['default_language'] = ‘ja’;

$CONF['database_type'] = ‘mysql’;
$CONF['database_host'] = ‘localhost’;
$CONF['database_user'] = ‘postfix’;
$CONF['database_password'] = ‘Lr9WNUJK’;
$CONF['database_name'] = ‘postfix’;
$CONF['database_prefix'] = ”;

//$CONF['encrypt'] = ‘md5crypt’;
$CONF['encrypt'] = ‘cleartext’;

$CONF['page_size'] = ’100′;

//$CONF['domain_path'] = ‘NO’;
$CONF['domain_path'] = ‘YES’;

// Default Domain Values
// Specify your default values below. Quota in MB.
$CONF['aliases'] = ’100′;
$CONF['mailboxes'] = ’100′;
$CONF['maxquota'] = ’300′;

// Quota
// When you want to enforce quota for your mailbox users set this to ‘YES’.
$CONF['quota'] = ‘NO’;

$CONF['backup'] = ‘NO’;

$CONF['sendmail'] = ‘NO’;

$CONF['fetchmail'] = ‘NO’;

$CONF['footer_text'] = ‘Postfix Admin Top’;
$CONF['footer_link'] = ‘http://www.example.com/postfixadmin/’;

$CONF['emailcheck_resolve_domain']=’NO’;
[root@localhost]# groupadd -g 10000 vuser
[root@localhost]# useradd -g vuser -u 10000 vuser
[root@localhost]# mkdir /mail
[root@localhost]# chown vuser:vuser /mail
[root@localhost]# chmod 771 /mail
[root@localhost]# vi /etc/postfix/mysql_virtual_alias_maps.cf
user = root
password =
hosts = localhost
dbname = postfix
table = alias
select_field = goto
where_field = address

[root@localhost]# vi /etc/postfix/mysql_virtual_domains_maps.cf
user = root
password =
hosts = localhost
dbname = postfix
table = domain
select_field = domain
where_field = domain
additional_conditions = and active = ’1′

[root@localhost]# vi /etc/postfix/mysql_virtual_mailbox_maps.cf
user = root
password =
hosts = localhost
dbname = postfix
table = mailbox
select_field = maildir
where_field = username

[root@localhost]# vi /etc/postfix/mysql_virtual_mailbox_limit_maps.cf
user = root
password =
hosts = localhost
dbname = postfix
table = mailbox
select_field = quota
where_field = username
#additional_conditions = and active = ’1′

[root@localhost]# cp /etc/postfix/main.cf /etc/postfix/main.cf.org
[root@localhost]# vi /etc/postfix/main.cf
myhostname = mail.example.com
mydomain = example.com
#myorigin = $mydomain
myorigin = $myhostname

#inet_interfaces = localhost
inet_interfaces = all

#mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
mydestination =

#relay_domains = $mydestination
relay_domains = $mydestination

home_mailbox = Maildir/

smtpd_banner = $myhostname ESMTP unknown

local_transport = virtual
virtual_transport = virtual
virtual_mailbox_base = /mail
virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
virtual_alias_domains = $virtual_alias_maps
virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
virtual_minimum_uid = 10000
virtual_uid_maps = static:10000
virtual_gid_maps = static:10000

maximal_backoff_time = 800s
minimal_backoff_time = 100s
bounce_queue_lifetime = 60m
maximal_queue_lifetime = 60m

#mailbox_size_limit = 1024000000
message_size_limit = 20480000

#virtual_mailbox_limit = 51200000
virtual_mailbox_limit_maps = mysql:/etc/postfix/mysql_virtual_mailbox_limit_maps.cf
virtual_mailbox_limit_override = yes
virtual_overquota_bounce = yes
virtual_mailbox_limit_inbox = yes

smtpd_sasl_auth_enable = yes
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_local_domain = $myhostname
smtpd_client_restrictions = reject_rbl_client bl.spamcop.net
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination

[root@localhost]# yum -y install dovecot

[root@localhost]# chkconfig dovecot on
[root@localhost]# chkconfig –list dovecot
[root@localhost]# cp /etc/dovecot.conf /etc/dovecot.conf.org
[root@localhost]# vi /etc/dovecot.conf
#protocols = imap imaps pop3 pop3s
protocols = pop3 imap

mail_location = maildir:/mail/%d/%u

first_valid_uid = 10000
first_valid_gid = 10000

#passdb pam {

#}

passdb sql {
args = /etc/dovecot-mysql.conf
}

#userdb passwd {
#}

userdb sql {
args = /etc/dovecot-mysql.conf
}

#mechanisms = plain
mechanisms = plain login digest-md5 cram-md5

protocol pop3 {
pop3_uidl_format = %08Xu%08Xv
}

socket listen {
client {
path = /var/spool/postfix/private/auth
mode = 0660
user = postfix
group = postfix
}
}

x86_64の場合は以下を設定
——————————————————————————-
login_process_size = 64
——————————————————————————-

[root@localhost]# vi /etc/dovecot-mysql.conf
driver = mysql
default_pass_scheme = PLAIN
connect = dbname=postfix user=postfix host=/var/lib/mysql/mysql.sock password=Lr9WNUJK
password_query = SELECT password FROM mailbox WHERE username = ‘%u’ AND active = ’1′
user_query = SELECT concat(‘/mail/’, maildir) as home, 10000 as uid, 10000 as gid FROM mailbox WHERE username = ‘%u’ AND active = ’1′

[root@localhost]# yum -y install cyrus-sasl-plain cyrus-sasl-md5
[root@localhost]# /etc/rc.d/init.d/saslauthd stop
[root@localhost]# chkconfig saslauthd off
[root@localhost]# chkconfig dovecot on
[root@localhost]# chkconfig postfix on
[root@localhost]# /etc/init.d/dovecot start
[root@localhost]# /etc/init.d/postfix start

ブラウザからPostfixAdminのページにアクセス

http://XXX.XXX/PostfixAdmin/setup.php

あとは表示にそって設定

コメント(1)

  1. 1SMTPサーバー不正中継テスト - CentOS設定メモ

    [...] 2月03日 22:43 admin 前回(CentOS5.4でPostfix+MySQL+PostfixAdmin)の続き。 [...]

    返信

コメントのRSSを取得する · トラックバック

コメントする