Home > Linux > document > 正文

搭建基于虚拟域和虚拟用户的linux最新开源邮件系统Postfix+Dovecot+Cyrus-sasl+roundcubemail+mysql+postfixadmin

.搭建配置缩略图

.系统环境准备

(1).软件准备

 (2).域名映射准备,一个域名,做好A记录,MX记录,SPF记录

Xishui139.com

 

 

(3).邮件服务器需要固定的外网ip地址.做必须的端口映射25.110

180.166.35.68

.开始安装邮件服务器

1.linux fedora 22系统的安装步骤这里略过,需要注意的是如果邮件服务器需要对用户做磁盘限制,请给存放邮件的目录单独划分磁盘

2.fedorared hat家族的软件,可以yum安装的软件有Apache,php,mysql,postfix, cyrus-sasl, dovecot,这里不再介绍

3.重点介绍courier-authlib的编译安装

从官网www.courier-mta.org下载courier-authlib-0.62.4.tar.bz2的安装包,格式是.tar.bz2

解压的命令是tar jxvf courier-authlib-0.62.4.tar.bz2

我使用的编译安装命令是

./configure    --prefix=/usr/local/authlib --with-mailuser=postfix --with-mailgroup=vmail   --sysconfdir=/etc    --without-authpam    --without-authldap    --without-authpwd    --without-authshadow    --without-authvchkpw --without-authpgsql --with-authmysql    --with-mysql-libs=/usr/lib/mysql    --with-mysql-includes=/usr/include/mysql --with-redhat    --with-authmysqlrc=/etc/authmysqlrc --with-authdaemonrc=/etc/authdaemonrc

注意:命令需要校对目录是否正确,如果不需要的参数删除,

如果遇到报错,只需要按照提示安装上需要的包即可.

重要参数

(1). --with-mysql-includes=/usr/include/mysql   mysql库文件路径

(2). -with-authmysqlrc=/etc/authmysqlrc --with-authdaemonrc=/etc/authdaemonrc

安装完成后生成的配置文件位置,不加参数没有此文件

(3). --without-authpam    --without-authldap    --without-authpwd    --without-authshadow    --without-authvchkpw --without-authpgsql --with-authmysql

without不加的功能,with 启用的认证功能

(4) --with-mailuser=postfix postfix身份安装并后续运行此程序

(5). --prefix=/usr/local/authlib编译安装的路径

(6).编译命令记录

.配置邮件服务器

(1).这里是本机于上周配置的系统账号验证的完整参数,

Linux 邮件服务器postfix+dovecot配置参数

(2).dovecot配置

以下这些配置足够正常运行你的postfix for 虚拟域用户

queue_directory = /var/spool/postfix

command_directory = /usr/sbin

daemon_directory = /usr/libexec/postfix

data_directory = /var/lib/postfix

myhostname = mail.xishui139.com

 #主机名

mydomain = xishui139.com

#@后面的domain

myorigin = $mydomain

# domain相同

inet_interfaces = all

inet_protocols = all

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

#虚拟域需要仅仅注销mydestination(注意)

unknown_local_recipient_reject_code = 550

mynetworks_style = class

mynetworks = 127.0.0.0/8,192.168.198.0/24

#局域网络

alias_maps = hash:/etc/aliases

alias_database = hash:/etc/aliases

home_mailbox = Maildir/

#邮件存储格式

debug_peer_level = 2

debugger_command =

         PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin

         ddd $daemon_directory/$process_name $process_id & sleep 5

meta_directory = /etc/postfix

shlib_directory = no

# Virtual mailbox settings.

#mydestination = localhost, proxy:mysql:/etc/postfix/mysql-mydestination.cf

virtual_mailbox_base = /home/vmail

#mailbox的格式需要在postfix,dovecot,各自定义在相同的目录

virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf

virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf

virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf

#配置文件没有则需要创建

virtual_uid_maps = static:89

#此处的id=89postfixidgid

virtual_gid_maps = static:89

virtual_minimum_uid = 89

#postfixgid uid    (id postfix 查询)

virtual_transport = virtual

#Message_size_limit = 10240000

virtual_mailbox_limit = 209715200

#Additional for quota support

virtual_create_maildirsize = yes

virtual_mailbox_extended = yes

virtual_mailbox_limit_maps = mysql:/etc/postfix/mysql_virtual_limit_maps.cf

virtual_mailbox_limit_override = yes

virtual_maildir_limit_message = Sorry, the user's maildir has exceeded the quota.

virtual_overquota_bounce = yes

# SASL settings

#mail_location = Maildir/

smtpd_sasl_auth_enable = yes

#打开smtp认证

smtpd_sasl_local_domain = $mydomain

smtpd_sasl_security_options = noanonymous

#smtpd_sasl_type = dovecot

#smtpd_sasl_path = /run/dovecot/auth-login

broken_sasl_auth_clients = yes

smtpd_recipient_restrictions = permit_mynetworks,

permit_sasl_authenticated,

reject_unauth_destination,

reject_invalid_hostname,

reject_non_fqdn_hostname,

reject_non_fqdn_sender,

reject_non_fqdn_recipient

smtpd_sasl_security_restrictions =

permit_mynetworks,

permit_sasl_authenticated,

reject_unauth_destination

(2).1. virtual相关配置

1.1 Vi mysql-mydestination.cf

user = postfix

password = password

dbname = postfix

table = transport

select_field = domain

#字段名字,存储domain

where_field = domain

hosts = localhost

1.2  vi mysql_virtual_alias_maps.cf

user = postfix

password = password

hosts = localhost

dbname = postfix

table = alias

#表名

select_field = goto

where_field = address

additional_conditions = and active = '1'

1.3 vi mysql_virtual_mailbox_maps.cf

user = postfix

password = password

hosts = localhost

dbname = postfix

table = mailbox

select_field = CONCAT(domain,'/',maildir)

where_field = username

additional_conditions = and active = '1'

1.4 vi mysql_virtual_domains_maps.cf

user = postfix

password = password

hosts = localhost

dbname = postfix

table = domain

select_field = domain

where_field = domain

additional_conditions = and active = '1'

1.5  vi mysql_relay_domains_maps.cf

user = postfix

password = postfixpassword

hosts = localhost

dbname = postfix

table = domain

select_field = domain

where_field = domain

additional_conditions == and backupmx == '1'

(2).2 dovecot报错分析

这个报错是系统软件刚装好启动后,还没有进行设置时候的状态,需要使用sasl进行认证配置

按照上面的参数,postfix 基本没有问题

(3).cyrus-saslcourier-auth的连接需要注意.

#正确pwcheck_method: authdaemond

#错误pwcheck_method: saslauthd

 

(4). cyrus-sasl配置

(4).1  vi /etc/sysconfig/saslauthd

SOCKETDIR=/run/saslauthd

MECH=shadow

#认证方式

FLAGS=

(4).2 vi /etc/sasl2/smtpd.conf

pwcheck_method: authdaemond

mech_list: PLAIN LOGIN

#认证方式

log_level: 3

#saslauthd_path:/var/run/saslauthd/mux

authdaemond_path: /usr/local/authlib/var/spool/authdaemon/socket

注意:courier-authlib需要成功启动,才会在/usr/local/authlib/var/spool/authdaemon/生成socket文件

pwcheck_method需要是authdaemond才能使用courier-auth进行mysql账号认证

(5). Courier-auth配置

(5).1 vi /etc/authdaemon

authmodulelist="authmysql"

daemons=5

authdaemonvar=/usr/local/authlib/var/spool/authdaemon

DEBUG_LOGIN=2

DEFAULTOPTIONS=""

LOGGEROPTS=""

(5).2   vi /etc/authmysqlrc

MYSQL_SERVER    localhost

MYSQL_USERNAME    postfix

MYSQL_PASSWORD    password

MYSQL_SOCKET    /var/lib/mysql/mysql.sock

#mysql.Socket文件路径指定实际路径最稳妥

MYSQL_PORT    3306

MYSQL_OPT        0

MYSQL_DATABASE        postfix

MYSQL_USER_TABLE    mailbox

MYSQL_CRYPT_PWFIELD    password

MYSQL_UID_FIELD    89

MYSQL_GID_FIELD    89

#postfixuiggid

MYSQL_LOGIN_FIELD    username

MYSQL_HOME_FIELD    maildir

MYSQL_NAME_FIELD    name

MYSQL_MAILDIR_FIELD    concat('/vmail/',maildir)

(6) . dovecot配置

base_dir = /var/run/dovecot/

first_valid_uid = 0

last_valid_uid = 5001

listen = *

login_greeting = mail.xishui139.com pop3/imap server ready.

login_trusted_networks = 0.0.0.0/0

mail_location = maildir:/vmail/%d/%d/%n/

#maildir路径(%d表示domain,%n 表示user)

mbox_write_locks = fcntl

passdb {

  args = /etc/dovecot/dovecot-mysql.conf

  driver = sql

}

protocols = imap pop3

ssl = required

ssl_cert = </etc/pki/dovecot/certs/dovecot.pem

ssl_key = </etc/pki/dovecot/private/dovecot.pem

#支持993 995加密端口

userdb {

  driver = passwd

}

#系统账号验证密码

userdb {

  args = /etc/dovecot/dovecot-mysql.conf

  driver = sql

}

#定义连接mysql认证账号

(7).mysql数据库表空间创建配置,存储用户数据

(mysql表空间语句引用http://wiki.ubuntu.org.cn  搭建邮件服务器.)

Setting up Database, Users, and Privileges

Connect to MySQL database as root

mysql -u root -p

Then type the following sql commands.

To use MySQL user database:

USE mysql;

To create Postfix user & set password

mysql>INSERT INTO user (Host, User, Password) VALUES ('localhost','postfix',password(' password '));

mysql>INSERT INTO db (Host, Db, User, Select_priv) VALUES ('localhost','postfix','postfix','Y');

To create Postfix Admin user & set password:

mysql>INSERT INTO user (Host, User, Password) VALUES ('localhost','postfixadmin',password('postfixadmin'));

mysql>INSERT INTO db (Host, Db, User, Select_priv, Insert_priv, Update_priv, Delete_priv) VALUES ('localhost', 'postfix', 'postfixadmin', 'Y', 'Y', 'Y', 'Y');

mysql>FLUSH PRIVILEGES;

To Add Privileges for users:

mysql>GRANT USAGE ON postfix.* TO postfix@localhost;

mysql>GRANT SELECT, INSERT, DELETE, UPDATE ON postfix.* TO postfix@localhost;

mysql>GRANT USAGE ON postfix.* TO postfixadmin@localhost;

mysql>GRANT SELECT, INSERT, DELETE, UPDATE ON postfix.* TO postfixadmin@localhost;

To create and use the database:

mysql>CREATE DATABASE postfix;

mysql>USE postfix;

Create the Table Admin

This table is used create the administrators for our virtual mail system. The admin user will be able create, modify, and delete virtadomain administrators, mailboxes and other administrative tasks in the mail system. Postfix is not using this table.

Copy and paste the sql statement to your mysql> prompt.

CREATE TABLE admin (

username varchar(255) NOT NULL default '',

password varchar(255) NOT NULL default '',

created datetime NOT NULL default '0000-00-00 00:00:00',

modified datetime NOT NULL default '0000-00-00 00:00:00',

active tinyint(1) NOT NULL default '1',

PRIMARY KEY  (username),

KEY username (username)

) TYPE=MyISAM COMMENT='Postfix Admin - Virtual Admins';

Create the Alias table

Postfix is using the "address" and "goto" column. Courier is not using this table.

attachment:IconHint.png

This table can be used for virtual .forward files. This table is nothing more than /etc/aliases that you will find on any *nix OS. Multiple destination email addresses need to be separated by a "," (comma).

Following is the table structure for table alias. Copy and paste the sql statement to your mysql> prompt

CREATE TABLE alias (

address varchar(255) NOT NULL default '',

goto text NOT NULL,

domain varchar(255) NOT NULL default '',

created datetime NOT NULL default '0000-00-00 00:00:00',

modified datetime NOT NULL default '0000-00-00 00:00:00',

active tinyint(1) NOT NULL default '1',

PRIMARY KEY  (address),

KEY address (address)

) TYPE=MyISAM COMMENT='Postfix Admin - Virtual Aliases';

Create the Domain table

Postfix is using the "domain" and "description" column. Courier is not using this table.

Copy and paste the sql statement to your mysql> prompt

CREATE TABLE domain (

domain varchar(255) NOT NULL default '',

description varchar(255) NOT NULL default '',

aliases int(10) NOT NULL default '0',

mailboxes int(10) NOT NULL default '0',

maxquota int(10) NOT NULL default '0',

transport varchar(255) default NULL,

backupmx tinyint(1) NOT NULL default '0',

created datetime NOT NULL default '0000-00-00 00:00:00',

modified datetime NOT NULL default '0000-00-00 00:00:00',

active tinyint(1) NOT NULL default '1',

PRIMARY KEY  (domain),

KEY domain (domain)

) TYPE=MyISAM COMMENT='Postfix Admin - Virtual Domains';

 

Create the Domain Admin Table

Table structure for table domain_admins. This table is used to create individual administrators for each virtual domain. Postfix or Courier is not using this table.

Copy and paste the sql statement to your mysql> prompt.

CREATE TABLE domain_admins (

username varchar(255) NOT NULL default '',

domain varchar(255) NOT NULL default '',

created datetime NOT NULL default '0000-00-00 00:00:00',

active tinyint(1) NOT NULL default '1',

KEY username (username)

) TYPE=MyISAM COMMENT='Postfix Admin - Domain Admins';

Create the Mailbox Table

Postfix is using the "username" and "maildir" column while Courier is using the "username", "password", "name" and "maildir" column.

Copy and paste the sql statement to your mysql> prompt.

CREATE TABLE mailbox (

username varchar(255) NOT NULL default '',

password varchar(255) NOT NULL default '',

name varchar(255) NOT NULL default '',

maildir varchar(255) NOT NULL default '',

quota int(10) NOT NULL default '0',

domain varchar(255) NOT NULL default '',

created datetime NOT NULL default '0000-00-00 00:00:00',

modified datetime NOT NULL default '0000-00-00 00:00:00',

active tinyint(1) NOT NULL default '1',

PRIMARY KEY  (username),

KEY username (username)

) TYPE=MyISAM COMMENT='Postfix Admin - Virtual Mailboxes';

Create the Log Table

Postfix or Courier is not using this table. Instead this table is used to log the activities of domain administrators and mailbox users.

Copy and paste the sql statement to your mysql> prompt.

CREATE TABLE log (

timestamp datetime NOT NULL default '0000-00-00 00:00:00',

username varchar(255) NOT NULL default '',

domain varchar(255) NOT NULL default '',

action varchar(255) NOT NULL default '',

data varchar(255) NOT NULL default '',

KEY timestamp (timestamp)

) TYPE=MyISAM COMMENT='Postfix Admin - Log';

Create the Vacation Table

Virual Vacation is done with a local shell account that can receive email. The email is then handled by a Perl script which sends the Vacation message back to the sender.

Copy and paste the sql statement to your mysql> prompt.

CREATE TABLE vacation (

email varchar(255) NOT NULL default '',

subject varchar(255) NOT NULL default '',

body text NOT NULL,

cache text NOT NULL,

domain varchar(255) NOT NULL default '',

created datetime NOT NULL default '0000-00-00 00:00:00',

active tinyint(1) NOT NULL default '1',

PRIMARY KEY  (email),

KEY email (email)

) TYPE=MyISAM COMMENT='Postfix Admin - Virtual Vacation';

(8)telnet测试smtppo3 以及imap是否正常

注意:需要使用printf "xishui139@xishui139.com" | openssl base64(生成base64编码以供验证)

(8).1Smtp 测试

最后结果表明账号验证成功,此处的账号需要完全的电子邮件地址如:xishui139@xishui139.com

(8).1  pop3 测试

Logged in表示登陆认证成功

(8).2  imap 测试

Logged in表示登陆认证成功

至此已经可以正常的使用邮件收发功能

(9) 常规日志排错(在排查错误之前,需要打开postfix,dovecot,mysqlcourier-auth的日志功能,以便于查看完整的日志报错,方便排查)

1.Sasl认证错误

总结:认证方式不对,courier-auth没有正确配置

2.dovecot 认证问题

Jul  4 21:02:36 localhost postfix/master[4017]: terminating on signal 15

Jul  4 21:02:37 localhost postfix/postfix-script[5253]: starting the Postfix mail system

Jul  4 21:02:37 localhost postfix/master[5255]: daemon started -- version 3.0.1, configuration /etc/postfix

Jul  4 21:17:49 localhost postfix/smtpd[5753]: connect from localhost.localdomain[127.0.0.1]

Jul  4 21:17:49 localhost postfix/smtpd[5753]: warning: SASL: Connect to /var/lib/dovecot/run/dovecot/auth-login failed: Permission denied

Jul  4 21:17:49 localhost postfix/smtpd[5753]: fatal: no SASL authentication mechanisms

Jul  4 21:17:50 localhost postfix/master[5255]: warning: process /usr/libexec/postfix/smtpd pid 5753 exit status 1

Jul  4 21:17:50 localhost postfix/master[5255]: warning: /usr/libexec/postfix/smtpd: bad command startup -- throttling

Jul  4 21:19:30 localhost postfix/anvil[5755]: statistics: max connection rate 1/60s for (smtp:127.0.0.1) at Jul  4 21:17:49

Jul  4 21:19:30 localhost postfix/anvil[5755]: statistics: max connection count 1 for (smtp:127.0.0.1) at Jul  4 21:17:49

Jul  4 21:19:30 localhost postfix/anvil[5755]: statistics: max cache size 1 at Jul  4 21:17:49

总结:没有配置认证参数,导致提示权限不足,选择postfix认证,或者dovecot自身认证.mysql认证都可以.

3.postfix认证问题

Jul  4 22:59:20 localhost postfix/master[7912]: terminating on signal 15

Jul  4 22:59:21 localhost postfix/postfix-script[8140]: starting the Postfix mail system

Jul  4 22:59:21 localhost postfix/master[8142]: daemon started -- version 3.0.1, configuration /etc/postfix

Jul  4 22:59:31 localhost postfix/smtpd[8151]: connect from localhost.localdomain[127.0.0.1]

Jul  4 22:59:31 localhost postfix/smtpd[8151]: fatal: no SASL authentication mechanisms

Jul  4 22:59:32 localhost postfix/master[8142]: warning: process /usr/libexec/postfix/smtpd pid 8151 exit status 1

Jul  4 22:59:32 localhost postfix/master[8142]: warning: /usr/libexec/postfix/smtpd: bad command startup -- throttling

Jul  4 23:04:54 localhost postfix/postfix-script[8320]: refreshing the Postfix mail system

总结:初始配置,未做sasl认证. no SASL authentication mechanisms

4.pop3登陆查询存储邮件问题

Jul  5 00:23:23 localhost dovecot: pop3-login: Login: user=<xishui139>, method=PLAIN, rip=192.168.198.18, lip=192.168.198.18, mpid=10162, secured, session=<ePRnFw8a7ADAqMYS>

Jul  5 00:23:23 localhost dovecot: pop3(xishui139): Error: User initialization failed: Namespace '': Mail storage autodetection failed with home=/home/xishui139

Jul  5 00:23:23 localhost dovecot: pop3(xishui139): Error: Invalid user settings. Refer to server log for more information.

Jul  5 00:25:29 localhost dovecot: pop3-login: Login: user=<xishui139>, method=PLAIN, rip=192.168.198.18, lip=192.168.198.18, mpid=10198, secured, session=<NK/qHg8a7QDAqMYS>

Jul  5 00:25:29 localhost dovecot: pop3(xishui139): Error: User initialization failed: Namespace '': Mail storage autodetection failed with home=/home/xishui139

Jul  5 00:25:29 localhost dovecot: pop3(xishui139): Error: Invalid user settings. Refer to server log for more information.

总结: 邮件存储自动检测失败,就是dovecot和系统已经创建的目录不匹配,dovecot也没有权限在配置的目录创建mail目录

5.dovecot 邮件目录没有配置报错

Jul  5 00:30:28 localhost dovecot: master: Dovecot v2.2.18 starting up for imap, pop3, lmtp (core dumps disabled)

Jul  5 00:30:38 localhost dovecot: pop3-login: Aborted login (no auth attempts in 8 secs): user=<>, rip=192.168.198.18, lip=192.168.198.18, secured, session=<hhFfMQ8a7wDAqMYS>

Jul  5 00:30:49 localhost dovecot: pop3-login: Login: user=<xishui139>, method=PLAIN, rip=192.168.198.18, lip=192.168.198.18, mpid=10317, secured, session=<iS8FMg8a8ADAqMYS>

Jul  5 00:30:49 localhost dovecot: pop3(xishui139): Error: User initialization failed: Namespace '': Root mail directory not given

Jul  5 00:30:49 localhost dovecot: pop3(xishui139): Error: Invalid user settings. Refer to server log for more information.

Jul  5 00:34:41 localhost dovecot: pop3-login: Login: user=<xishui139>, method=PLAIN, rip=192.168.198.18, lip=192.168.198.18, mpid=10355, secured, session=<qQLTPw8a8QDAqMYS>

Jul  5 00:34:41 localhost dovecot: pop3(xishui139): Error: User initialization failed: Namespace '': Root mail directory not given

Jul  5 00:34:41 localhost dovecot: pop3(xishui139): Error: Invalid user settings. Refer to server log for more information.

总结:配置mail目录

6.virtual 和系统使用的uidgid有差异,报错

Jul  5 01:38:21 localhost postfix/qmgr[9629]: 53320C13C4: from=<i_j@live.cn>, size=530, nrcpt=1 (queue active)

Jul  5 01:38:21 localhost postfix/virtual[10858]: warning: recipient user01@xishui139.com: bad uid 89 in virtual_uid_mapsJul  5 01:38:21 localhost postfix/virtual[10858]: 53320C13C4: to=<user01@xishui139.com>, relay=virtual, delay=4739, delays=4739/0.14/0/0.06, dsn=4.3.5, status=deferred (mail system configuration error)

此时我在virtual使用的uidgid5000

7.地址账号不存在

Jul  5 10:15:53 localhost postfix/smtpd[15739]: NOQUEUE: reject: RCPT from mail.xishui139.com[192.168.198.18]: 550 5.1.1 <pulish>: Recipient address rejected: User unknown in local recipient table; from=<xishui139> to=<pulish> proto=ESMTP helo=<mail>

总结:本地账号不存在.

8.提供的认证方式都失败

Jul  5 10:53:14 localhost dovecot: pop3-login: Aborted login (tried to use disallowed plaintext auth): user=<>, rip=180.166.35.68, lip=192.168.198.18, session=<F4/t4xcajwC0piNE>

Jul  5 10:53:21 localhost postfix/smtpd[16155]: connect from mail.xishui139.com[192.168.198.18]

总结,按照提供的认证进行正确的认证.

9.virtual认证接收地址不存在

Jul  9 11:19:44 localhost postfix/smtpd[20010]: connect from unknown[180.166.35.68]

Jul  9 11:19:44 localhost authdaemond: received auth request, service=smtp, authtype=login

Jul  9 11:19:44 localhost authdaemond: authmysql: trying this module

Jul  9 11:19:44 localhost authdaemond: SQL query: SELECT username, password, "", 89, 89, maildir, concat('/vmail/',maildir), "", name, "" FROM mailbox WHERE username = 'smtp_blog@xishui139.com'

Jul  9 11:19:44 localhost authdaemond: password matches successfully

Jul  9 11:19:44 localhost authdaemond: authmysql: sysusername=<null>, sysuserid=89, sysgroupid=89, homedir=xishui139.com/smtp_blog/, address=smtp_blog@xishui139.com, fullname=smtp_blog, maildir=/vmail/xishui139.com/smtp_blog/, quota=<null>, options=<null>

Jul  9 11:19:44 localhost authdaemond: authmysql: clearpasswd=<null>, passwd=$1$ecde18f9$PLg5AdxChGH3enyVgfUI21

Jul  9 11:19:44 localhost authdaemond: Authenticated: sysusername=<null>, sysuserid=89, sysgroupid=89, homedir=xishui139.com/smtp_blog/, address=smtp_blog@xishui139.com, fullname=smtp_blog, maildir=/vmail/xishui139.com/smtp_blog/, quota=<null>, options=<null>

Jul  9 11:19:44 localhost authdaemond: Authenticated: clearpasswd=123456, passwd=$1$ece1f9PLgAdxCnygfU21

Jul  9 11:19:44 localhost postfix/smtpd[20010]: NOQUEUE: reject: RCPT from unknown[180.166.35.68]: 550 5.1.1 <user@xishui139.com>: Recipient address rejected: User unknown in virtual mailbox table; from=<smtp_blog@xishui139.com> to=<user@xishui139.com> proto=ESMTP helo=<mail.xishui139.com>

总结:mysql mailbox中创建收件人地址.

10.virtual smtp认证失败

Jul 10 21:33:29 localhost postfix/smtpd[7059]: warning: localhost.localdomain[127.0.0.1]: SASL login authentication failed: another step is needed in authentication

总结:密码不正确

11.SQL 语句不正确

Jul  9 09:04:15 localhost authdaemond: received auth request, service=smtp, authtype=login

Jul  9 09:04:15 localhost authdaemond: authmysql: trying this module

Jul  9 09:04:15 localhost authdaemond: authmysqllib: connected. Versions: header 100020, client 100020, server 100020Jul  9 09:04:15 localhost authdaemond: SQL query: SELECT username, crypt, "", 5000, 5000, concat('/home/',homedir, concat('/home/',maildir), "", name, "" FROM mailbox WHERE username = 'smtp_blog@xishui139.com'Jul  9 09:04:15 localhost authdaemond: mysql_query failed, reconnecting: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'FROM mailbox WHERE username = 'smtp_blog@xishui139.com'' at line 1

Jul  9 09:04:15 localhost authdaemond: authmysqllib: connected. Versions: header 100020, client 100020, server 100020Jul  9 09:04:15 localhost authdaemond: mysql_query failed second time, giving up: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'FROM mailbox WHERE username = 'smtp_blog@xishui139.com'' at line 1

Jul  9 09:04:15 localhost authdaemond: authmysql: TEMPFAIL - no more modules will be tried

Jul  9 09:04:15 localhost postfix/smtpd[18296]: warning: SASL authentication failure: could not verify password

Jul  9 09:04:15 localhost postfix/smtpd[18296]: warning: unknown[180.166.35.68]: SASL LOGIN authentication failed: generic failure

Jul  9 09:04:15 localhost postfix/smtpd[18296]: disconnect from unknown[180.166.35.68] ehlo=1 auth=0/1 quit=1 commands=2/3

总结:sql查询语句不正确,就是/etc/authmysqlrc文件配置不正确

我的这个报错是因为MYSQL_HOME_FIELD    maildir  (错误配置MYSQL_HOME_FIELD    concat('/home/',homedir)

12.dovecotdovecotid进行数据查询报错

Jul  9 13:58:17 localhost dovecot: pop3-login: Login: user=<publish_blog>, method=PLAIN, rip=180.166.35.68, lip=192.168.198.18, mpid=21794, secured, session=<YjUY8WoaHQC0piNE>

Jul  9 13:58:17 localhost dovecot: pop3(publish_blog): Error: User initialization failed: Namespace '': mkdir(/home/vmail//publish_blog/Maildir) failed: Permission denied (euid=1004(publish_blog) egid=1004(publish_blog) missing +w perm: /home/vmail/, we're not in group 89(postfix), dir owned by 89:89 mode=0775)

Jul  9 13:58:17 localhost dovecot: pop3(publish_blog): Error: Invalid user settings. Refer to server log for more information.

Jul  9 13:58:47 localhost dovecot: pop3-login: Login: user=<aliyun_blog>, method=PLAIN, rip=114.215.116.149, lip=192.168.198.18, mpid=21796, secured, session=<hwLp8moa7ABy13SV>

Jul  9 13:58:47 localhost dovecot: pop3(aliyun_blog): Error: User initialization failed: Namespace '': mkdir(/home/vmail//aliyun_blog/Maildir) failed: Permission denied (euid=1001(aliyun_blog) egid=1001(aliyun_blog) missing +w perm: /home/vmail/, we're not in group 89(postfix), dir owned by 89:89 mode=0775)

Jul  9 13:58:47 localhost dovecot: pop3(aliyun_blog): Error: Invalid user settings. Refer to server log for more information.

总结: dovecotdovecotid进行数据查询报错,需要dovecotvirtual设置的uidgid进行查询,我设置的uidgid 89(postfix)

13. mail_location = maildir:/vmail/%d/%d/%n/ 多一个domain

Jul  9 15:17:46 localhost postfix/smtpd[22636]: BE0EAC1737: client=unknown[180.166.35.68], sasl_method=LOGIN, sasl_username=smtp_blog@xishui139.com

Jul  9 15:17:46 localhost postfix/cleanup[22643]: BE0EAC1737: message-id=<3020c63f6860e33db7d13931e8df156d@mail.xishui139.com>

Jul  9 15:17:46 localhost postfix/qmgr[18414]: BE0EAC1737: from=<smtp_blog@xishui139.com>, size=1705, nrcpt=1 (queue active)

Jul  9 15:17:46 localhost postfix/smtpd[22636]: disconnect from unknown[180.166.35.68] ehlo=1 auth=1 mail=1 rcpt=1 data=1 quit=1 commands=6

Jul  9 15:17:46 localhost postfix/virtual[22645]: BE0EAC1737: to=<user@xishui139.com>, relay=virtual, delay=0.03, delays=0.02/0/0/0.02, dsn=2.0.0, status=sent (delivered to maildir)

总结:这次设置对了,但是dovecotmaildir地址和virtualmaildir不一样需要进行调整于是有了参数mail_location = maildir:/vmail/%d/%d/%n/

14.不影响收发邮件的错误

Jul  9 15:22:15 localhost authdaemond: Authenticated: sysusername=<null>, sysuserid=89, sysgroupid=89, homedir=xishui139.com/smtp_blog/, address=smtp_blog@xishui139.com, fullname=smtp_blog, maildir=/vmail/xishui139.com/smtp_blog/, quota=<null>, options=<null>

总结:我的mail实际地址是/vmail/xishui139.com/xishui139.com/smtp_blog/目录,但是这个错误不影响收发邮件的原因是postfix把收发信的工作交给了virtual

reply=virtual.virtualmaildirdovecotmaildir已经设置在相同的目录下,因此收发邮件就正常了.postfix只是担当了 (转收发往本地外地的请求)

15.迁移旧目录邮件到新目录报错

Jul  9 16:04:01 localhost dovecot: imap(user@xishui139.com): Error: open(/vmail/xishui139.com/xishui139.com/user/cur/1436116338.Vfd01Ic1a3fM378499.localhost.localdomain:2,S) failed: Permission denied (euid=89(postfix) egid=89(postfix) missing +r perm: /vmail/xishui139.com/xishui139.com/user/cur/1436116338.Vfd01Ic1a3fM378499.localhost.localdomain:2,S)

总结:客户端报错,不能收发邮件,因为复制的邮件权限属于root更改邮件的权限为postfix 89:89 即可/

可以看到12.排错dovecot的目录邮件更正.

201579i_j@live.cn

结束

上一篇:Linux open source mail server build (postfix+dovecot+roundcubemail)
下一篇:linux扩展根目录磁盘空间(linux lvm )
postfix check virus error

postfix check virus error

linux postfix install spf check

linux postfix install spf check

Linux open source mail server build (postfix+dovecot+roundcubemail)

Linux open source mail server build (postfix+dovecot+roundcubemail)

wordpress构架

wordpress构架

国内影响已扩散,利用“NSA武器库”中漏洞的Wannacry蠕虫勒索软件袭击全球(含修复方案)

国内影响已扩散,利用“NSA武器库”中漏洞的Wannacry蠕虫勒索软件袭击全球(含修复方案)

思科Talos团队深度解析“WannaCry”勒索软件

思科Talos团队深度解析“WannaCry”勒索软件

首发 | Wannacry勒索软件母体主程序逆向分析(含临时解决方案自动化工具)

首发 | Wannacry勒索软件母体主程序逆向分析(含临时解决方案自动化工具)

发表评论

您必须 [ 登录 ] 才能发表留言!

沙发空闲中,快来抢!