Mail server (CentOS, Postfix, Dovecot, SASL2, MySQL, PostfixAdmin)

Posted on Sun 11 July 2010 by Pavlo Khmel

Content:

  1. Preparation
  2. DNS
  3. MySQL
  4. Postfix with MySQL + SASL2
  5. Dovecot
  6. Apache + PostfixAdmin
  7. Web Interface (Roundcube)
  8. Install Amavisd-new, ClamAv и Spamassassin
  9. Additional
  10. Links

0. Preparation

Installation inside VirtualBox 3.2.6 or VmWare Player 3.1
OS: CentOS 5.5
IP: 10.0.2.15
Domain: khmel.org.local
Mail server name: mx.khmel.org
Disable SELinux and Firewall

system-config-securitylevel-tui

Install VirtualBox guest drivers

yum install gcc kernel-devel
ln -s /usr/src/kernels/2.6.18-194.3.1.el5-i686/ /usr/src/linux
sh /media/VBOXADDITIONS_3.2.6_63112/VBoxLinuxAdditions-x86.orgn
reboot

VmWare Player 3.1 guest drivers

cp /media/VMware Tools/VMwareTools-8.4.2-261024.tar.gz /root
tar -xvzf VMwareTools-8.4.2-261024.tar.gz
vmware-tools-distrib/vmware-install.pl
reboot

Network configuration

File /etc/sysconfig/network

NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=mx.khmel.org.local

File /etc/sysconfig/network-scripts/ifcfg-eth0

# Intel Corporation 82540EM Gigabit Ethernet Controller
DEVICE=eth0
BOOTPROTO=none
HWADDR=08:00:27:9A:3F:BC
ONBOOT=yes
TYPE=Ethernet
USERCTL=no
IPV6INIT=no
PEERDNS=yes
NETMASK=255.255.255.0
IPADDR=10.0.2.15
GATEWAY=10.0.2.2

File /etc/resolv.conf

nameserver 192.168.18.2

Emails will be stored in /usr/mail (more disk space) instead of /var/spool/mail

$ useradd -s /sbin/nologin -d /usr/mail virtual
$ grep virtual /etc/passwd
virtual:x:501:501::/usr/mail:/sbin/nologin

1. DNS

Install DNS server with chroot support

yum install bind-chroot

Autorun

$ chkconfig named on
$ chkconfig --list named
named 0:off 1:off 2:on 3:on 4:on 5:on 6:off

Create file 1 /var/named/chroot/etc/named.conf

options {
listen-on port 53 { 10.0.2.15; };
directory "/var/named";;
allow-query { any; };
recursion no;
allow-transfer { none; };
version "no version info";
};
include "/var/named/zone.conf";

Create file 2 /var/named/chroot/var/named/zone.conf

zone "khmel.org.local" IN {
type master;
file "khmel.org.local.conf";
allow-update { none; };
};

Create file 3 /var/named/chroot/var/named/khmel.org.local.conf

$TTL 3600
khmel.org.local. IN SOA mx.khmel.org.local. root.khmel.org.local. (
20010610 ; Serial
10800 ; Refresh
3600 ; Retry
604800 ; Expire
86400 ) ; Minimum TTL
@ IN NS mx.khmel.org.local.
@ IN A 10.0.2.15
www IN CNAME @
@ IN MX 10 mx.khmel.org.local.
mx IN A 10.0.2.15

Change /etc/resolv.conf, first DNS server is our

[root@mx ~]# vi
nameserver 10.0.2.15
nameserver 10.10.12.1
nameserver 10.10.10.1

Change /etc/hosts

127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
10.0.2.15 mx.khmel.org.local

Run and check DNS server

$ service named start
$ dig mx.khmel.org.local
...
mx.khmel.org.local. 3600 IN A 10.0.2.15
...
khmel.org.local. 3600 IN NS mx.khmel.org.local.
...

2. MySQL

Install

$ yum install mysql-server
$ chkconfig mysqld on
$ chkconfig --list mysqld
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off

Configure to listen only localhost in file /etc/my.cnf

[mysqld]
log=/var/log/mysqld.log
bind-address=127.0.0.1
...

MySQL start

service mysqld start

Set password and other settings

/usr/bin/mysql_secure_installation

Create user database for PostfixAdmin

mysql -u root -p
mysql> CREATE DATABASE postfix;
mysql> CREATE USER postfix@localhost IDENTIFIED BY 'postfix';
mysql> GRANT ALL PRIVILEGES ON postfix.* TO postfix;
mysql> quit

3. Postfix with MySQL + SASL2

Repository "centosplus" has compiled binary. Add to file /etc/yum.repos.d/CentOS-Base.repo

[base]
exclude=postfix
...
[updates]
exclude=postfix
....
[centosplus]
....
enabled=1
includepkgs=postfix
....

Install

yum install postfix
# Check:
postconf -m | grep mysql
chkconfig postfix on

Create file /etc/postfix/alias.conf

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

Create file /etc/postfix/domain.conf

user = postfix
password = postfix
hosts = localhost
dbname = postfix
table = domain
select_field = domain
where_field = domain
additional_conditions = and active = '1' and backupmx = '0'

Create file /etc/postfix/mailbox.conf

user = postfix
password = postfix
hosts = localhost
dbname = postfix
table = mailbox
select_field = maildir
where_field = username
additional_conditions = and active = '1'

Create file /etc/postfix/quota.conf

user = postfix
password = postfix
hosts = localhost
dbname = postfix
table = mailbox
select_field = quota
where_field = username
additional_conditions = and active = '1'

Create file /etc/postfix/sender.conf

user = postfix
password = postfix
hosts = localhost
dbname = postfix
table = mailbox
select_field = username
where_field = username
additional_conditions = and active = '1'

Edit file /etc/postfix/main.cf

queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
mail_owner = postfix
default_privs = nobody
myhostname = mx.khmel.org.local
mydomain = khmel.org.local
myorigin = $mydomain
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost
unknown_local_recipient_reject_code = 550
mynetworks = 127.0.0.0/8
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
smtpd_banner = $myhostname ESMTP
debug_peer_level = 2
# RESTRICTIONS START
smtpd_sender_restrictions = permit_mynetworks, reject_authenticated_sender_login_mismatch, reject_unknown_sender_domain, reject_unlisted_sender, reject_unverified_sender
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, permit_auth_destination, reject_unauth_destination, reject_unlisted_recipient, reject_unknown_recipient_domain, reject_non_fqdn_recipient, reject
smtpd_data_restrictions = reject_unauth_pipelining, reject_multi_recipient_bounce
smtpd_etrn_restrictions = reject
smtpd_reject_unlisted_sender = yes
disable_vrfy_command = yes
strict_rfc821_envelopes = yes
show_user_unknown_table_name = no
address_verify_sender = <>
unverified_sender_reject_code = 550
smtpd_helo_required = yes
smtp_always_send_ehlo = yes
smtpd_hard_error_limit = 8
smtpd_timeout = 120s
smtp_helo_timeout = 60s
smtp_mail_timeout = 60s
smtp_rcpt_timeout = 90s
# RESTRICTIONS END
# SMTP AUTH START
smtpd_sasl_auth_enable = yes
broken_sasl_auth_clients = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_application_name = smtpd
# SMTP AUTH END
smtpd_sender_login_maps = mysql:/etc/postfix/sender.conf
virtual_alias_maps = mysql:/etc/postfix/alias.conf
virtual_mailbox_domains = mysql:/etc/postfix/domain.conf
virtual_mailbox_maps = mysql:/etc/postfix/mailbox.conf
virtual_mailbox_limit_maps = mysql:/etc/postfix/quota.conf
virtual_maildir_extended=yes
virtual_mailbox_limit_override=yes
virtual_create_maildirsize = yes
virtual_overquota_bounce = yes
virtual_maildir_limit_message="Sorry, the user's maildir has overdrawn his diskspace quota, please try again later"
message_size_limit = 5242880
virtual_mailbox_base = /usr/mail
virtual_gid_maps = static:501
virtual_uid_maps = static:501
virtual_minimum_uid = 500

Switch SendMail to Postfix

$ alternatives --config mta
There are 2 programs which provide 'mta'.
Selection Command
-----------------------------------------------
*+ 1 /usr/sbin/sendmail.sendmail
2 /usr/sbin/sendmail.postfix
Enter to keep the current selection[+], or type selection number: 2
service sendmail stop
service postfix start
newaliases

Install SQL for SASL2

yum install cyrus-sasl-sql
chkconfig saslauthd on

Edit file /usr/lib/sasl2/smtpd.conf
For x86_64 /usr/lib64/sasl2

pwcheck_method: auxprop
mech_list: PLAIN LOGIN CRAM-MD5
auxprop_plugin: sql
sql_engine: mysql
sql_hostnames: localhost
sql_user: postfix
sql_passwd: postfix
sql_database: postfix
sql_select: select password from mailbox where username = '%u@%r'
log_level: 3

Start servive

service saslauthd start

4. Dovecot

yum install dovecot
chkconfig dovecot on

If you need SSL sertificate (not used in this article)

Edit /etc/pki/dovecot/dovecot-openssl.cnf

[ req ]
default_bits = 1024
encrypt_key = yes
distinguished_name = req_dn
x509_extensions = cert_type
prompt = no
[ req_dn ]
C=UA
L=Kiev
OU=IMAP server
CN=imap.example.com
emailAddress=postmaster@khmel.org.local
[ cert_type ]
nsCertType = server

Create new sertificate

/usr/share/doc/dovecot-1.0.7/examples/mkcert.sh

Configure Dovecot in file /etc/dovecot.conf

protocols = pop3 imap
protocol pop3 {
listen = *:110
}
protocol imap {
listen = *:143
}
disable_plaintext_auth = no
log_path = /var/log/dovecot.log
info_log_path = /var/log/dovecot.log
login_greeting = Welcome to khmel.org IMAP/POP3 server.
mail_location = maildir:/usr/mail/%d/%n
mail_debug = yes
first_valid_uid = 501
last_valid_uid = 501
first_valid_gid = 501
last_valid_gid = 501
auth_verbose = yes
auth_debug = yes
auth_debug_passwords = yes
auth default {
mechanisms = plain login cram-md5 DIGEST-MD5
passdb sql {
args = /etc/dovecot-mysql.conf
}
userdb sql {
args = /etc/dovecot-mysql.conf
}
user = virtual
}

Create /etc/dovecot-mysql.conf

driver = mysql
connect = host=/var/lib/mysql/mysql.sock dbname=postfix user=postfix password=postfix
default_pass_scheme = PLAIN
password_query = SELECT username as user, password FROM mailbox WHERE username = '%u' and active='1'
user_query = SELECT maildir, 501 AS uid, 501 AS gid FROM mailbox WHERE username = '%u' and active='1' Запускаем:

Start service

service dovecot start

5. Apache + PostfixAdmin

Apache + PHP needed for PostfixAdmin

yum install httpd php php-mysql php-imap php-mbstring
chkconfig httpd on

Install PostfixAdmin

cd /var/www/html/
wget http://downloads.sourceforge.net/project/postfixadmin/postfixadmin/postfixadmin_2.3.tar.gz?use_mirror=netcologne
tar -xvzf postfixadmin_2.3.tar.gz
mv postfixadmin-2.3/ postfixadmin
service httpd start


Use first time http://mx.khmel.org.local/postfixadmin/setup.php

Change configuration
cp /var/www/html/postfixadmin/config.inc.php /var/www/html/postfixadmin/config.inc.php.original
Edit /var/www/html/postfixadmin/config.inc.php
$CONF[configured] = true;
$CONF[setup_password] = ec5152bbbb9803f3877604568e9c125b:969677d1a0c336f4e07d9fc52130f0aea7eb70f3;
$CONF[postfix_admin_url] = http://mx.khmel.org.local/postfixadmin’;
$CONF[postfix_admin_path] = dirname(FILE);
$CONF[default_language] = en;
$CONF[database_type] = mysql;
$CONF[database_host] = localhost;
$CONF[database_user] = postfix;
$CONF[database_password] = postfix;
$CONF[database_name] = postfix;
$CONF[database_prefix] = ;
$CONF[database_prefix] = ;
$CONF[database_tables] = array (
admin => admin,
alias => alias,
alias_domain => alias_domain,
config => config,
domain => domain,
domain_admins => domain_admins,
fetchmail => fetchmail,
log => log,
mailbox => mailbox,
vacation => vacation,
vacation_notification => vacation_notification,
quota => quota,
quota2 => quota2,
);
$CONF[admin_email] = postmaster@khmel.org.local;
$CONF[smtp_server] = localhost;
$CONF[smtp_port] = 25;
$CONF[encrypt] = cleartext;
$CONF[authlib_default_flavor] = md5raw;
$CONF[dovecotpw] = /usr/sbin/dovecotpw;
$CONF[min_password_length] = 5;
$CONF[generate_password] = NO;
$CONF[show_password] = NO;
$CONF[page_size] = 10;
$CONF[default_aliases] = array (
abuse => abuse@khmel.org.local,
hostmaster => hostmaster@khmel.org.local,
postmaster => postmaster@khmel.org.local,
webmaster => webmaster@khmel.org.local
);
$CONF[domain_path] = YES;
$CONF[domain_in_mailbox] = NO;
$CONF[aliases] = 10;
$CONF[mailboxes] = 10;
$CONF[maxquota] = 10;
$CONF[quota] = NO;
$CONF[quota_multiplier] = 1024000;
$CONF[transport] = NO;
$CONF[transport_options] = array (
virtual, // for virtual accounts
local, // for system accounts
relay // for backup mx
);
$CONF[transport_default] = virtual;
$CONF[vacation] = NO;
$CONF[vacation_domain] = autoreply.mx.khmel.org.local;
$CONF[vacation_control] =YES;
$CONF[vacation_control_admin] = YES;
$CONF[alias_control] = NO;
$CONF[alias_control_admin] = NO;
$CONF[special_alias_control] = NO;
$CONF[alias_goto_limit] = 0;
$CONF[alias_domain] = YES;
$CONF[backup] = YES;
$CONF[sendmail] = YES;
$CONF[logging] = YES;
$CONF[fetchmail] = YES;
$CONF[fetchmail_extra_options] = NO;
$CONF[show_header_text] = NO;
$CONF[header_text] = :: Postfix Admin ::;
$CONF[user_footer_link] = http://mx.khmel.org.local/postfixadmin/main”;
$CONF[show_footer_text] = YES;
$CONF[footer_text] = Return to mx.khmel.org.local/postfixadmin/;
$CONF[footer_link] = http://mx.khmel.org.local/postfixadmin’;
$CONF[welcome_text] = << Hi,
Welcome to your new account.
EOM;
$CONF[emailcheck_resolve_domain]=YES;
$CONF[show_status]=NO;
$CONF[show_status_key]=NO;
$CONF[show_status_text]= ;
$CONF[show_undeliverable]=NO;
$CONF[show_undeliverable_color]=tomato;
$CONF[show_undeliverable_exceptions]=array(unixmail.domain.ext,exchangeserver.domain.ext,gmail.com);
$CONF[show_popimap]=NO;
$CONF[show_popimap_color]=darkgrey;
$CONF[show_custom_domains]=array(subdomain.domain.ext,domain2.ext);
$CONF[show_custom_colors]=array(lightgreen,lightblue);
$CONF[recipient_delimiter] = “”;
$CONF[create_mailbox_subdirs_prefix]=INBOX.;
$CONF[used_quotas] = NO;
$CONF[new_quota_table] = NO;
$CONF[theme_logo] = images/logo-default.png;
$CONF[theme_css] = css/default.css;
$CONF[xmlrpc_enabled] = false;
if (file_exists(dirname(FILE) . /config.local.php)) {
include(dirname(FILE) . /config.local.php);
}
    One more time use http://mx.khmel.org.local/postfixadmin/setup.php to create admin user.
    Then login http://mx.khmel.org.local/postfixadmin/
    Create domain: Domain List > New Domain: Domain = khmel.org.local, Description: phn, Aliases = 0, Mailboxes = 0, And mark "Add default mail aliases:" press "Add Domain".

    Admin mailbox should be created first !!!!
    Add mailbox: Virtual List > Add Mailbox: Username = linux, Password = postfix, Password (again) = postfix, Name = linux. Mark Active and Send Welcome mail.

    "Send Welcome mail:" will create user mail directory

    Client setup Evolution as example:

    Email address: linux@khmel.org.local
    Server Type: POP
    Server: mx.khmel.org.local
    Username: linux@khmel.org.local
    Mark: Leave messages on server
    Mark: Remember password
    Server Type: SMTP
    Server: mx.khmel.org.local
    Mark: Server requires authentication
    Username: linux@khmel.org.local
    Mark: Remember password

    **6. Web Interface (Roundcube)**

    Download http://roundcube.net and install
mv roundcubemail-0.3.1.tar.gz /var/www/html/  
cd /var/www/html/  
tar -xvzf roundcubemail-0.3.1.tar.gz  
cp roundcubemail-0.3.1 roundcube  
mysql -u root -p

> CREATE DATABASE roundcubemail /*!40101 CHARACTER SET utf8 COLLATE utf8\_general\_ci \*/;  
> GRANT ALL PRIVILEGES ON roundcubemail.* TO roundcube\@localhost IDENTIFIED BY '123456';  
> quit  
> mysql -u roundcube -p roundcubemail \< /var/www/html/roundcube/SQL/mysql.initial.sql  
> cp roundcube/config/db.inc.php.dist roundcube/config/db.inc.php

Edit in file roundcube/config/db.inc.php

\$rcmail\_config\['db\_dsnw'\] = 'mysql://roundcube:123456\@localhost/roundcubemail';

Edit file roundcube/config/main.inc.php

cp roundcube/config/main.inc.php.dist roundcube/config/main.inc.php  
\$rcmail\_config\['default\_host'\] = 'mx.khmel.org.local';  
\$rcmail\_config\['create\_default\_folders'\] = TRUE;

Use http://mx.khmel.org.local/roundcube

Install Amavisd-new, ClamAv и Spamassassin (!!! Not checked, not finished !!!)

Amavisd-new not in CentOS repositories use Dag Wieers/RPMForge http://dag.wieers.com/rpm/FAQ.php#B

rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm  
yum install yum-priorities

Add to /etc/yum.repos.d/CentOS-Base.repo in "base", "addons", "updates", и "extras"

    priority=1

in "centosplus" and "contrib"

    priority=2

Full example

    [base]
    priority=1
    exclude=postfix
    name=CentOS-$releasever - Base
    mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
    #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
    #released updates
    [updates]
    priority=1
    excluse=postfix
    name=CentOS-$releasever - Updates
    mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
    #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
    #packages used/produced in the build but not released
    [addons]
    priority=1
    name=CentOS-$releasever - Addons
    mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=addons
    #baseurl=http://mirror.centos.org/centos/$releasever/addons/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
    #additional packages that may be useful
    [extras]
    priority=1
    name=CentOS-$releasever - Extras
    mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
    #baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
    #additional packages that extend functionality of existing packages
    [centosplus]
    priority=2
    name=CentOS-$releasever - Plus
    mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
    #baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
    gpgcheck=1
    enabled=1
    includepkgs=postfix
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
    #contrib - packages by Centos Users
    [contrib]
    priority=2
    name=CentOS-$releasever - Contrib
    mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
    #baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/
    gpgcheck=1
    enabled=0
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

Add to file /etc/yum.repos.d/rpmforge.repo

    priority=11

File /etc/yum.repos.d/rpmforge.repo

    # Name: RPMforge RPM Repository for Red Hat Enterprise 5 - dag
    # URL: http://rpmforge.net/
    [rpmforge]
    priority=11
    name = Red Hat Enterprise $releasever - RPMforge.net - dag
    #baseurl = http://apt.sw.be/redhat/el5/en/$basearch/dag
    mirrorlist = http://apt.sw.be/redhat/el5/en/mirrors-rpmforge
    #mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge
    enabled = 1
    protect = 0
    gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
    gpgcheck = 1

Check

    yum check-update

Install ClamAV and Spamassassin

    yum install clamav clamav-milter spamassassin
    chkconfig spamassassin on
    chkconfig clamd on
    chkconfig clamav-milter on
    service spamassassin start
    amavisd-new:
    yum install amavisd-new
    chkconfig amavisd on

    Change in /etc/amavisd.conf

\$mydomain = 'khmel.org.local';

Add at the end of file /etc/postfix/main.cf

    content_filter = amavisd-new:[127.0.0.1]:10024

Add at the add of file /etc/postfix/master.cf

    amavisd-new unix - - n - 2 smtp
     -o smtp_data_done_timeout=1200s
     -o disable_dns_lookups=yes
    127.0.0.1:10025 inet n - n - - smtpd
     -o content_filter=
     -o local_recipient_maps=
     -o relay_recipient_maps=
     -o smtpd_restriction_classes=
     -o smtpd_client_restrictions=
     -o smtpd_helo_restrictions=
     -o smtpd_sender_restrictions=
     -o smtpd_recipient_restrictions=permit_mynetworks,reject
     -o mynetworks=127.0.0.0/8
     -o strict_rfc821_envelopes=yes

!!! Tab character should be in frong of -о!!!

    service spamassassin start
    service clamd start
    service clamav-milter start
    service amavisd start

Try send bad email

    telnet 10.0.2.15 25
    Trying 10.0.2.15...
    Connected to 10.0.2.15 (10.0.2.15).
    Escape character is '^]'.
    220 mx.khmel.org.local ESMTP
    ehlo mx.khmel.org.local
    250-mx.khmel.org.local
    250-PIPELINING
    250-SIZE 5242880
    250-ETRN
    250-AUTH LOGIN CRAM-MD5 PLAIN
    250-AUTH=LOGIN CRAM-MD5 PLAIN
    250-ENHANCEDSTATUSCODES
    250-8BITMIME
    250 DSN
    MAIL FROM:
    250 2.1.0 Ok
    RCPT TO:
    250 2.1.5 Ok
    DATA
    354 End data with .
    SUBJECT: TEST SPAM
    XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X
    .
    250 2.0.0 Ok: queued as 29FB11A260E
    quit
    221 2.0.0 Bye
    Connection closed by foreign host.

Check

    $ cat /var/log/maillog | grep 29FB11A260E
    Jun 29 22:00:45 mx postfix/smtpd[4421]: 29FB11A260E: client=unknown[10.0.2.15]
    Jun 29 22:01:28 mx postfix/cleanup[4431]: 29FB11A260E: message-id=<20100629190045.29FB11A260E@mx.khmel.org.local>
    Jun 29 22:01:28 mx postfix/qmgr[4415]: 29FB11A260E: from=, size=449, nrcpt=1 (queue active)
    Jun 29 22:01:39 mx amavis[4264]: (04264-01) Blocked SPAM, [10.0.2.15] [10.0.2.15] -> , quarantine: spam-hqXjbter6qTa.gz, Message-ID: <20100629190045.29FB11A260E@mx.khmel.org.local>, mail_id: hqXjbter6qTa, Hits: 1005.782, size: 449, 10346 ms
    Jun 29 22:01:39 mx postfix/smtp[4437]: 29FB11A260E: to=, relay=127.0.0.1[127.0.0.1]:10024, delay=78, delays=67/0.17/0.04/10, dsn=2.5.0, status=sent (250 2.5.0 Ok, id=04264-01, DISCARD(bounce.suppressed))
    Jun 29 22:01:39 mx postfix/qmgr[4415]: 29FB11A260E: removed

Additional

Postfix copy sent emails for example user\@mydomain.org copy to backup\@mydomain.org

In master.cf add

backup unix - n n - - pipe flags=R user=postfix argv=/etc/postfix/script ${sender} ${recipient}

File /etc/postfix/script

```bash
#!/bin/bash
/usr/sbin/sendmail -f $1 $2 backup@mydomain.org

Add in main.cf:

smtpd_sender_restrictions = `<add to the end of this line>`, hash:/etc/postfix/smtpd.sender

Create file /etc/postfix/smtpd.sender

user@mydomain.org FILTER backup:

restart

postmap smtpd.sender
postfix reload

9. Links

  1. http://unix-notes.org/2009/09/14/ustanovka-bind-named-na-centos
  2. http://www.linuxmail.info/postfix-mysql-centos-5
  3. http://www.sys-adm.org.ua/mail/mail-howto-p1.php
  4. http://www.sys-adm.org.ua/mail/dovecot.php
  5. http://www.linuxmail.info/postfix-admin-howto-centos-5
  6. http://postfixmail.com/blog/index.php/clamav-and-spamassassin-on-centos-5-postfix
  7. http://www.sys-adm.org.ua/mail/mail-howto-p2.php