- 论坛徽章:
- 0
|
postfix 顯示s_connect failed錯誤, 兩個星期都未解決到問題
我的安裝過程如下:
1. cyrus-sasl-2.1.20 Install
cd cyrus-sasl-2.1.20
./configure --enable-anon --enable-plain --enable-login --enable-sql --disable-krb4 --disable-otp --enable-cram --enable-digest --with-mysql=/usr/local/mysql/lib/mysql --without-pam --without-saslauthd --without-pwcheck --with-dblib=berkeley --with-bdb-libdir=/usr/local/bdb/lib --with-bdb-incdir=/usr/local/bdb/include --with-openssl=/usr/local/ssl --with-plugindir=/usr/local/lib/sasl2
make
make install
ln -s /usr/local/lib/sasl2 /usr/lib/sasl2
2.postfix install
pw groupadd postdrop -g 87
pw groupadd postfix -g 88
pw useradd postfix -u 88 -g 88 -d /usr/local/testmail -s /nonexistent
tar -zxf postfix-2.2.2.tar.gz
cd postfix-2.2.2
make makefiles 'CCARGS=-DHAS_MYSQL -I/usr/local/mysql/include/mysql -DUSE_SASL_AUTH -I/usr/local/include/sasl -DHAS_DB -I/usr/local/bdb/include -DUSE_TLS -I/usr/local/ssl/include/openssl ' 'AUXLIBS=-L/usr/local/mysql/lib/mysql -lmysqlclient -lz -lm -L/usr/local/lib -lsasl2 -L/usr/local/bdb/lib -ldb -L/usr/local/ssl/lib -lssl -lcrypto'
make install
cd ..
3.smtp.conf setup
vi /usr/local/lib/sasl2/smtpd.conf
# smtpd.conf
pwcheck_method: auxprop
auxprop_plugin: sql
mech_list: plain login
sql_engine: mysql
sql_hostnames: localhost
sql_user: testemail
sql_passwd: wang1268
sql_database: testmail
sql_select: select clear from postfix_users where email='%u@%r' and smtpaccess='Y';
sql_verbose: yes
4. mysql setup
CREATE TABLE postfix_alias (
id int(11) unsigned NOT NULL auto_increment,
alias varchar(12 NOT NULL default '',
destination varchar(12 NOT NULL default '',
PRIMARY KEY (id)
) TYPE=MyISAM;
CREATE TABLE postfix_relocated (
id int(11) unsigned NOT NULL auto_increment,
email varchar(12 NOT NULL default '',
destination varchar(12 NOT NULL default '',
PRIMARY KEY (id)
) TYPE=MyISAM;
CREATE TABLE postfix_transport (
id int(11) unsigned NOT NULL auto_increment,
domain varchar(12 NOT NULL default '',
destination varchar(12 NOT NULL default '',
PRIMARY KEY (id),
UNIQUE KEY domain (domain)
) TYPE=MyISAM;
CREATE TABLE postfix_virtual_domains (
id int(11) unsigned NOT NULL auto_increment,
domain varchar(12 NOT NULL default '',
destination varchar(12 NOT NULL default '',
PRIMARY KEY (id),
UNIQUE KEY domain (domain)
) TYPE=MyISAM;
CREATE TABLE postfix_users (
id int(11) unsigned NOT NULL auto_increment,
email varchar(12 NOT NULL default '',
clear varchar(12 NOT NULL default '',
crypt varchar(128) NOT NULL default '',
name tinytext NOT NULL,
uid int(11) unsigned NOT NULL default '89',
gid int(11) unsigned NOT NULL default '89',
homedir tinytext NOT NULL,
maildir tinytext NOT NULL,
quota tinytext NOT NULL,
access enum('Y','N') NOT NULL default 'Y',
postfix enum('Y','N') NOT NULL default 'Y',
disablepop3 char(1) NOT NULL default '0',
disableimap char(1) NOT NULL default '0',
disablewebmail char(1) NOT NULL default '0',
sharedgroup varchar(128) NOT NULL default '0',
smtpaccess enum('Y','N') NOT NULL default 'Y',
PRIMARY KEY (id),
UNIQUE KEY email (email)
) TYPE=MyISAM;
CREATE TABLE postfix_virtual (
id int(11) unsigned NOT NULL auto_increment,
email varchar(128) NOT NULL default '',
destination varchar(128) NOT NULL default '',
PRIMARY KEY (id)
) TYPE=MyISAM;
CREATE TABLE postfix_access (
id int(10) unsigned NOT NULL auto_increment,
source varchar(128) NOT NULL default '',
access varchar(128) NOT NULL default '',
type enum('recipient','sender','client') NOT NULL default 'recipient',
PRIMARY KEY (id)
) TYPE=MyISAM ;
vi mysql-aliases.cf
# mysql-aliases.cf
user = testemail
password = wang1268
dbname = testmail
table = postfix_alias
select_field = destination
where_field = alias
hosts = localhost
vi mysql-relocated.cf
# mysql-relocated.cf
user = testemail
password = wang1268
dbname = testmail
table = postfix_relocated
select_field = destination
where_field = email
hosts = localhost
vi mysql-transport.cf
# mysql-transport.cf
user = testemail
password = wang1268
dbname = testmail
table = postfix_transport
select_field = destination
where_field = domain
hosts = localhost
vi mysql-virtual-domains.cf
# mysql-virtual-domains.cf
user = testemail
password = wang1268
dbname = testmail
table = postfix_virtual_domains
select_field = destination
where_field = domain
hosts = localhost
vi mysql-virtual.cf
# mysql-virtual.cf
user = testemail
password = wang1268
dbname = testmail
table = postfix_virtual
select_field = destination
where_field = email
hosts = localhost
vi mysql-recipient.cf
# mysql-recipient.cf
user = testemail
password = wang1268
dbname = testmail
table = postfix_access
select_field = access
where_field = source
additional_conditions = and type = 'recipient'
hosts = localhost
vi mysql-sender.cf
# mysql-sender.cf
user = testemail
password = wang1268
dbname = testmail
table = postfix_access
select_field = access
where_field = source
additional_conditions = and type = 'sender'
hosts = localhost
vi mysql-client.cf
# mysql-client.cf
user = testemail
password = wang1268
dbname = testmail
table = postfix_access
select_field = access
where_field = source
additional_conditions = and type = 'client'
hosts = localhost
vi mysql-virtual-maps.cf
# mysql-virtual-maps.cf
user = testemail
password = wang1268
dbname = testmail
table = postfix_users
select_field = maildir
where_field = email
additional_conditions = and postfix = 'y'
hosts = localhost
vi mysql-virtual-uid.cf
# mysql-virtual-uid.cf
user = testemail
password = wang1268
dbname = testmail
table = postfix_users
select_field = uid
where_field = email
additional_conditions = and postfix = 'y'
hosts = localhost
vi mysql-virtual-gid.cf
# mysql-virtual-gid.cf
user = testemail
password = wang1268
dbname = testmail
table = postfix_users
select_field = gid
where_field = email
additional_conditions = and postfix = 'y'
hosts = localhost
chmod 640 /etc/postfix/mysql-*
chgrp postfix /etc/postfix/mysql-*
5 main.cf setup
vi /etc/postfix/main.cf
myhostname = test.testhk.com
mydomain = testhk.com
mydestination = $myhostname
local_recipient_maps = $alias_maps $virtual_mailbox_maps unix:passwd.byname
home_mailbox = Maildir/
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain = $myhostname
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,
check_recipient_access mysql:/etc/postfix/mysql-recipient.cf,reject_unauth_destination,permit
#The above line must be fitted in one line DONT FORGET
smtpd_sender_restrictions = check_sender_access mysql:/etc/postfix/mysql-sender.cf
smtpd_client_restrictions = check_client_access mysql:/etc/postfix/mysql-client.cf
alias_maps = mysql:/etc/postfix/mysql-aliases.cf
relocated_maps = mysql:/etc/postfix/mysql-relocated.cf
transport_maps = mysql:/etc/postfix/mysql-transport.cf
maildrop_destination_recipient_limit = 1
virtual_transport = maildrop
virtual_mailbox_domains = mysql:/etc/postfix/mysql-virtual-domains.cf
virtual_alias_maps = mysql:/etc/postfix/mysql-virtual.cf
virtual_mailbox_base = /mailbox/vmail
virtual_mailbox_maps = mysql:/etc/postfix/mysql-virtual-maps.cf
virtual_uid_maps = mysql:/etc/postfix/mysql-virtual-uid.cf
virtual_gid_maps = mysql:/etc/postfix/mysql-virtual-gid.cf
#If you want to use TLS add three lines below
smtpd_use_tls = yes
smtpd_tls_cert_file = /etc/postfix/postfix.pem
smtpd_tls_key_file = $smtpd_tls_cert_file
#OPTIONAL PART
smtpd_helo_required = yes
disable_vrfy_command = yes
smtpd_data_restrictions = reject_unauth_pipelining
smtpd_etrn_restrictions = reject
6.courier-authlib-0.55 install
cd courier-authlib-0.55
./configure --prefix=/usr/local/authlib --enable-workarounds-for-imap-client-bugs --disable-root-check --with-authmysql --with-mysql-libs=/usr/local/mysql/lib/mysql --with-mysql-includes=/usr/local/mysql/include/mysql/ --with-authmysqlrc=/usr/local/etc/authlib/authmysqlrc --with-mailuser=courier --with-mailgroup=courier
make
make install
make install-configure
7. courier-imap-4.0.2 install
cd courier-imap-4.0.2
./configure --prefix=/usr/local/courier-imap --with-ssl --enable-workarounds-for-imap-client-bugs --with-authchangepwdir --enable-unicode --with-trashquota --disable-root-check
8.maildrop-1.8.0 install
./configure -enable-maildirquota --enable-maildrop-uid=vmail --enable-maildrop-gid=vmail --with-trashquota --enable-syslog=3
make
make install
9 imap and pop3d setup
cd /usr/local/etc/authlib
cp authdaemonrc.dist authdaemonrc
vi authdaemonrc
authmodulelist="authmysql authpam"
cp authmysqlrc.dist authmysqlrc
vi authmysqlrc
MYSQL_SERVER localhost
MYSQL_USERNAME testemail
MYSQL_PASSWORD wang1268
MYSQL_SOCKET /tmp/mysql.sock
#Use MYSQL_SOCKET instead of MYSQL_PORT.
#If you can't do that, use MYSQL_PORT
#If your socket path is in a different location, please modify it.
MYSQL_OPT 0
MYSQL_DATABASE testmail
MYSQL_USER_TABLE postfix_users
MYSQL_CRYPT_PWFIELD crypt
MYSQL_CLEAR_PWFIELD clear
MYSQL_UID_FIELD uid
MYSQL_GID_FIELD gid
MYSQL_LOGIN_FIELD email
MYSQL_HOME_FIELD homedir
MYSQL_NAME_FIELD name
MYSQL_MAILDIR_FIELD maildir
MYSQL_QUOTA_FIELD quota
MYSQL_AUXOPTIONS_FIELD
CONCAT("disableimap=",disableimap,",disablepop3=",disablepop3,",disablewebmail=",disablewebmail,",sharedgroup=",sharedgroup)
MYSQL_WHERE_CLAUSE access='y'
vi /usr/lib/courier-imap/etc/imapd
IMAPDSTART=YES
vi /usr/lib/courier-imap/etc/pop3d
POP3DSTART=YES
vi /usr/lib/courier-imap/etc/pop3d-ssl
POP3DSSLSTART=YES
vi /etc/maildroprc
if ( $SIZE < 26144 )
{
exception {
xfilter "/usr/bin/spamassassin --prefspath=$HOME/$DEFAULT/.spamassassin/user_prefs"
}
}
if (/^X-Spam-Flag: *YES/)
{
exception {
to "$HOME/$DEFAULT/.Spam/"
}
}
else
{
exception {
to "$HOME/$DEFAULT"
}
}
10. add user
/usr/local/mysql/bin/mysql -u testemail -pwang1268
use testmail;
INSERT INTO postfix_alias VALUES (1,'root@test.testhk.com','user0a@testhk.com');
INSERT INTO postfix_alias VALUES (2,'operator@test.testhk.com','user0a@testhk.com');
INSERT INTO postfix_virtual_domains VALUES (1,'testhk.com','maildrop');
INSERT INTO postfix_virtual_domains VALUES (2,'testcn.com','maildrop');
INSERT INTO postfix_virtual VALUES (1,'user0a@testhk.com','testhk.com');
INSERT INTO postfix_virtual VALUES (2,'operator@testhk.com','testhk.com');
INSERT INTO postfix_users (email,clear,crypt,name,homedir,maildir,quota) VALUES
('user0a@testhk.com','user0a1268','encrypt(user0a1268)','user0a','/testbox/vmail/','testhk.com/user0a/Maildir/','100000000');
mkdir -p /testbox/vmail/testhk.com/user0a
chown -R vmail:vmail /testbox/vmail/testhk.com/user0a/
chmod -R 700 /testbox/vmail/testhk.com/user0a/
/usr/local/courier-imap/bin/maildirmake /testbox/vmail/testhk.com/user0a/Maildir
/usr/local/courier-imap/bin/maildirmake -q 100000000S /testbox/vmail/testhk.com/user0a/Maildir
/usr/lib/courier-imap/bin/maildirmake -q 100000000S /testbox/vmail/testhk.com/user0a/Maildir |
|