Install Postfix

Install Postfix :

# apt-get install postfix-mysql

Reading package lists… Done
Building dependency tree
Reading state information… Done
The following NEW packages will be installed:
postfix-mysql
0 upgraded, 1 newly installed, 0 to remove and 18 not upgraded.
Need to get 43.4kB of archives.
After this operation, 111kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com jaunty/main postfix-mysql 2.5.5-1.1 [43.4kB]
Fetched 43.4kB in 4s (9540B/s)
Selecting previously deselected package postfix-mysql.
(Reading database … 23112 files and directories currently installed.)
Unpacking postfix-mysql (from …/postfix-mysql_2.5.5-1.1_i386.deb) …
Setting up postfix-mysql (2.5.5-1.1) …
Adding mysql map entry to /etc/postfix/dynamicmaps.cf

Configuration start :

1. Integrate Quota Patch

Install some helpfull program :

#apt-get install build-essential dpkg-dev fakeroot debhelper libdb-dev libldap2-dev  libpcre3-dev libmysqlclient15-dev  libssl-dev libsasl2-dev libpq-dev libcdb-dev hardening-wrapper

# cd /usr/src
# apt-get source postfix

# wget http://vda.sourceforge.net/VDA/postfix-2.5.5-vda-ng.patch.gz

# gunzip postfix-2.5.5-vda-ng.patch.gz

# cd postfix-2.5.5
# patch -p1 < ../postfix-2.5.5-vda-ng.patch
patching file README_FILES/VDA_README
patching file src/global/mail_params.h
patching file src/util/file_limit.c
patching file src/virtual/mailbox.c
patching file src/virtual/maildir.c
patching file src/virtual/virtual.c
patching file src/virtual/virtual.h
root@smsgw:/usr/src/postfix-2.5.5#

2. Rebuilding .deb file

#dpkg-buildpackage

#cd ..

#ls -l
total 5868
drwxr-xr-x 19 root root    4096 2009-03-29 12:21 postfix-2.5.5
-rw-r–r–  1 root src   236237 2009-03-29 12:17 postfix_2.5.5-1.1.diff.gz
-rw-r–r–  1 root src     1178 2009-03-29 12:17 postfix_2.5.5-1.1.dsc
-rw-r–r–  1 root src     3695 2009-03-29 12:22 postfix_2.5.5-1.1_i386.changes
-rw-r–r–  1 root src  1224324 2009-03-29 12:22 postfix_2.5.5-1.1_i386.deb
-rw-r–r–  1 root src  3157877 2008-09-03 11:04 postfix_2.5.5.orig.tar.gz
-rw-r–r–  1 root src    58389 2008-09-05 23:02 postfix-2.5.5-vda-ng.patch
-rw-r–r–  1 root src    41522 2009-03-29 12:22 postfix-cdb_2.5.5-1.1_i386.deb
-rw-r–r–  1 root src   141224 2009-03-29 12:22 postfix-dev_2.5.5-1.1_all.deb
-rw-r–r–  1 root src   914880 2009-03-29 12:22 postfix-doc_2.5.5-1.1_all.deb
-rw-r–r–  1 root src    48756 2009-03-29 12:22 postfix-ldap_2.5.5-1.1_i386.deb
-rw-r–r–  1 root src    43452 2009-03-29 12:22 postfix-mysql_2.5.5-1.1_i386.deb
-rw-r–r–  1 root src    43372 2009-03-29 12:22 postfix-pcre_2.5.5-1.1_i386.deb
-rw-r–r–  1 root src    43532 2009-03-29 12:22 postfix-pgsql_2.5.5-1.1_i386.deb

3. Install new postfix with patch applied

# dpkg -i postfix_2.5.5-1.1_i386.deb

# dpkg -i postfix-mysql_2.5.5-1.1_i386.deb

Create and secure the SMTP SSL certificate:

# mkdir -p /etc/ssl/postfix

# cd /etc/ssl/postfix/

#openssl req -new -x509 -nodes -out smtpd.pem -keyout smtpd.pem -days 3650

# chmod 640 /etc/ssl/postfix/smtpd.pem

# chgrp -R postfix /etc/ssl/postfix

Edit /etc/postfix/main.cf file:

# See /usr/share/postfix/main.cf.dist for a commented, more complete version

# Debian specific: Specifying a file name will cause the first
# line of that file to be used as the name. The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no

# appending .domain is the MUA’s job.
append_dot_mydomain = no

# Uncomment the next line to generate “delayed mail” warnings
#delay_warning_time = 4h

readme_directory = no

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

myhostname = mail.digitalfusi.com

mydomain = digitalfusi.com

alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = smsgw, localhost.localdomain, , localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
home_mailbox = Maildir/

#SASL stuff
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = reject_unknown_sender_domain, reject_unknown_recipient_domain, reject_unauth_pipelining, permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
smtpd_sender_restrictions =
permit_mynetworks,
permit_sasl_authenticated,
reject_non_fqdn_hostname,
reject_non_fqdn_sender,
reject_non_fqdn_recipient,
reject_unauth_destination,
reject_unauth_pipelining,
reject_invalid_hostname,
reject_rbl_client list.dsbl.org,
reject_rbl_client bl.spamcop.net,
reject_rbl_client sbl-xbl.spamhaus.org
smtpd_sasl_auth_enable = yes
smtpd_sasl_authenticated_header = yes
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_security_options = noanonymous
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/dovecot-auth

# MySQL Configuration
#
virtual_alias_maps = proxy:mysql:/etc/postfix/mysql_virtual_alias_maps.cf
virtual_gid_maps = static:125
virtual_mailbox_base = /usr/local/virtual
virtual_mailbox_domains = proxy:mysql:/etc/postfix/mysql_virtual_domains_maps.cf
virtual_mailbox_limit = 51200000
virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
virtual_minimum_uid = 125
virtual_transport = virtual
virtual_uid_maps = static:125

# TLS stuff

# TLS parameters
smtpd_tls_cert_file = /etc/ssl/certs/ssl-mail.pem
smtpd_tls_key_file = /etc/ssl/private/ssl-mail.key
smtpd_tls_CAfile = /etc/ssl/postfix/smtpd.pem
smtpd_use_tls = yes
smtpd_tls_loglevel = 0
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s

smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

mailbox_command = /usr/lib/dovecot/deliver -c /etc/dovecot/dovecot-postfix.conf -n -m “${EXTENSION}”

#smtpd_tls_auth_only = yes
tls_random_source = dev:/dev/urandom

# Quota support
#
virtual_create_maildirsize = yes
virtual_mailbox_extended = yes
virtual_mailbox_limit_maps = proxy:mysql:/etc/postfix/mysql_virtual_mailbox_limit_maps.cf
proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps
$virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains
$relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps
$recipient_canonical_maps $relocated_maps $transport_maps $mynetworks
$virtual_mailbox_limit_maps
virtual_mailbox_limit_override = yes
virtual_maildir_limit_message = Sorry, this user has overdrawn their diskspace quota. Please try again later.
virtual_overquota_bounce = yes

mydestination = localhost.$mydomain, localhost

relay_domains = proxy:mysql:/etc/postfix/mysql_relay_domains_maps.cf

Edit /etc/postfix/master.cf file:
Find and edit the RED TEXT.


smtps inet n – n – – smtpd
-o smtpd_tls_wrappermode=yes
-o smtpd_sasl_auth_enable=yes
-o smtpd_client_restrictions=permit_sasl_authenticated,reject

Create and edit /etc/postfix/mysql_virtual_alias_maps.cf file:

user = postfix
password = postfix_sql_password
hosts = localhost
dbname = postfix
query = SELECT goto FROM alias WHERE address=’%s’ AND active = ‘1

Create and edit /etc/postfix/mysql_virtual_domains_maps.cf file:

user = postfix
password = postfix_sql_password
hosts = localhost
dbname = postfix
query = SELECT domain FROM domain WHERE domain=’%s’ and backupmx = ‘0‘ and active = ‘1

Create and edit /etc/postfix/mysql_virtual_mailbox_maps.cf file:

user = postfix password = postfix_sql_password hosts = localhost dbname = postfix query = SELECT maildir FROM mailbox WHERE username=’%s’ AND active = ‘1

Create and edit /etc/postfix/mysql_virtual_mailbox_limit_maps.cf file:

user = postfix
password = postfix_sql_password
hosts = localhost
dbname = postfix
query = SELECT quota FROM mailbox WHERE username=’%s’

Create and edit /etc/postfix/mysql_relay_domains_maps.cf file:

user = postfix
password = postfix_sql_password
hosts = localhost
dbname = postfix
query = SELECT domain FROM domain WHERE domain=’%s’ and backupmx = ‘1

Secure Postfix’s MySQL files:

#chmod 640 /etc/postfix/mysql_*
#chgrp postfix /etc/postfix/mysql_*

Update the transport map database:

#touch /etc/postfix/transport

#postmap /etc/postfix/transport

Edit /etc/aliases file:

Change “root” to an email address you want system messages to be mailed to:
root:alamster@gmail.com
postmaster:    root
clamav: root

Create aliases.db file:

#/usr/bin/newaliases

Create our virtual mail directories:

#mkdir /usr/local/virtual
#chown -R postfix:postfix /usr/local/virtual
#chmod -R 700 /usr/local/virtual

  • Pages

  • Download Ubuntu

  • Download Fedora

  • Tags

    atmail open on ubuntu server change ip address check connection clamav continue install dns dovecot fuzzyocr install jaunty maia mailguard mysql New Virtual Disk Wizard nginx pear php postfix postfixadmin preparation roundcube mail Setting Virtual Machine spamassassin squirrelmail
  • Categories

    • Translate to: