Postfix mail server setup on ubuntu 8.04
Step 1: Install Postfix, Courier, Saslauthd, MySQL, phpMyAdmin
# apt-get install postfix postfix-mysql postfix-doc mysql-client mysql-server courier-authdaemon courier-authlib-mysql courier-pop courier-pop-ssl courier-imap courier-imap-ssl libsasl2-2 sasl2-bin libpam-mysql openssl phpmyadmin apache2 libapache2-mod-php5 php5 php5-mysql libpam-smbpass
You will be asked a few questions:
New password for the MySQL "root" user: <-- yourrootsqlpassword
Repeat password for the MySQL "root" user: <-- yourrootsqlpassword
Create directories for web-based administration? <-- No
General type of mail configuration: <-- Internet Site
System mail name: <-- server1.example.com
SSL certificate required <-- Ok
Web server to reconfigure automatically: <-- apache2
Step 2 :Create The MySQL Database For Postfix/Courier
#vim /etc/postfix/postfixadmin-mysql.sql
#Postfix Admin # by sahabdeen# License Info: http://www.postfixadmin.com/?file=LICENSE.TXT # # This is the complete MySQL database structure for Postfix Admin. # If you are installing from scratch you can use this file otherwise you # need to use the TABLE_CHANGES.TXT or TABLE_BACKUP_MX.TXT that comes with Postfix Admin. # # There are 2 entries for a database user in the file. # One you can use for Postfix and one for Postfix Admin. # # If you run this file twice (2x) you will get an error on the user creation in MySQL. # To go around this you can either comment the lines below "USE MySQL" until "USE postfix". # Or you can remove the users from the database and run it again. # # You can create the database from the shell with: # # mysql -u root [-p] < comment="'Postfix" comment="'Postfix" comment="'Postfix" comment="'Postfix" comment="'Postfix" comment="'Postfix" comment="'Postfix" size="3">#mysql -u root -p < /etc/postfix/postfixadmin-mysql.sql
Step 3:Creating Virtual Alias Maps:
#vim /etc/postfix/mysql_virtual_alias_maps.cf
user = postfix
password = postfixpassword
hosts = 127.0.0.1
dbname = postfix
table = alias
select_field = goto
where_field = address
# vim /etc/postfix/mysql_virtual_mailbox_maps.cf
user = postfix
password = postfixpassword
hosts = 127.0.0.1
dbname = postfix
table = mailbox
select_field = maildir
where_field = username
#additional_conditions = and active = '1'
#vim /etc/postfix/mysql_virtual_domains_maps.cf
user = postfix
password = postfixpassword
hosts = 127.0.0.1
dbname = postfix
table = domain
select_field = domain
where_field = domain
#additional_conditions = and backupmx = '0' and active = '1'
#vim /etc/postfix/mysql_virtual_mailbox_limit_maps.cf
user = postfix
password = postfixpassword
hosts = 127.0.0.1
dbname = postfix
table = mailbox
select_field = quota
where_field = username
#additional_conditions = and active = '1'
#vim /etc/postfix/mysql_relay_domains_maps.cf
user = postfix
password = postfixpassword
hosts = 127.0.0.1
dbname = postfix
table = domain
select_field = domain
where_field = domain
additional_conditions = and backupmx = '1'
#sudo chgrp postfix /etc/postfix/mysql_*.cf
#sudo chmod 640 /etc/postfix/mysql_*.cf
sudo groupadd -g 5000 vmail sudo useradd -m -g vmail -u 5000 -d /home/vmail -s /bin/bash vmail
Step 5:Configuring Postfix with MySQL maps
vim /etc/postfix/main.cf
# 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
# TLS parameters
smtpd_tls_cert_file = /etc/postfix/smtpd.cert
smtpd_tls_key_file = /etc/postfix/smtpd.key
smtpd_use_tls = yes
smtpd_tls_session_cache_database = btree:${queue_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${queue_directory}/smtp_scache
# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.
myhostname = gis.keltron.org
mydestination =
relayhost =
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mynetworks = 127.0.0.0/8
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
virtual_mailbox_limit = 51200000
virtual_minimum_uid = 5000
virtual_uid_maps = static:5000
virtual_gid_maps = static:5000
virtual_mailbox_base = /home/vmail
virtual_transport = virtual
# Additional for quota support
virtual_create_maildirsize = yes
virtual_mailbox_extended = yes
virtual_mailbox_limit_maps = mysql:/etc/postfix/mysql_virtual_mailbox_limit_maps.cf
virtual_mailbox_limit_override = yes
virtual_maildir_limit_message = Sorry, the your maildir has overdrawn your diskspace quota, please free up some of spaces of your mailbox try again.
virtual_overquota_bounce = yes
cd /var/www
#wget http://downloads.sourceforge.net/postfixadmin/postfixadmin-2.1.0.tgz?modtime=1105140809&big_mirror=0
#tar -xvgf postfixadmin_2.1.0.tar.gz
#cd postfixadmin_2.1.0
#vim DATABASE_MYSQL.TXT
delte all the entries under postfix/mysql
# mysql -upostfixadmin -p postfix < /var/www/postfixadmin-2.1.0/DATABASE_MYSQL.TXT
password=postfixadmin
# mv config.inc.php.sample config.inc.php
Courier-IMAP and Authentication Services
vim /etc/courier/authmysqlrc
MYSQL_SERVER 127.0.0.1
MYSQL_USERNAME postfixadmin
MYSQL_PASSWORD postfixadmin
MYSQL_DATABASE postfix
MYSQL_USER_TABLE mailbox
MYSQL_LOGIN_FIELD username
MYSQL_NAME_FIELD name
MYSQL_CRYPT_PWFIELD password
#MYSQL_CLEAR_PWFIELD password
MYSQL_MAILDIR_FIELD maildir
MYSQL_QUOTA_FIELD concat(quota,'S')
MYSQL_HOME_FIELD '/home/vmail'
MYSQL_UID_FIELD '5000'
MYSQL_GID_FIELD '5000'
/etc/init.d/courier-authdaemon restart /etc/init.d/courier-imap restart /etc/init.d/courier-pop restart tail -f /var/log/mail*
SMTP Authentication:
apt-get install libsasl2 libsasl2-modules libpam-mysql openssl
vim /etc/pam.d/smtp
auth required pam_mysql.so user=postfix passwd=postfixpassword host=127.0.0.1 db=postfix table=mailbox usercolumn=username passwdcolumn=password crypt=1 md5=1
account sufficient pam_mysql.so user=postfix passwd=postfixpassword host=127.0.0.1 db=postfix table=mailbox usercolumn=username passwdcolumn=password crypt=1 md5=1
vim /etc/postfix/sasl/smtpd.conf
pwcheck_method: saslauthd
mech_list: PLAIN LOGIN
log_level: 5
Edit the file /etc/default/saslauthd like this:
vim /etc/default/saslauthd
START=yes
MECHANISMS="pam"
OPTIONS="-c -r -m /var/spool/postfix/var/run/saslauthd"
mkdir /var/spool/postfix/var/
mkdir /var/spool/postfix/var/run/
mkdir /var/spool/postfix/var/run/saslauthd
chown -R root:sasl /var/spool/postfix/var/
chmod 710 /var/spool/postfix/var/run/saslauthd
adduser postfix sasl
ln -s /var/spool/postfix/var/run/saslauthd /var/run/saslauthd
vim /etc/postfix/main.cf
smtpd_recipient_restrictions = reject_unauth_pipelining, permit_mynetworks, permit_sasl_authenticated, reject_non_fqdn_recipient, reject_unauth_destination
# modify the existing smtpd_sender_restrictions
smtpd_sender_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_non_fqdn_sender, reject_unknown_sender_domain, reject_unauth_pipelining, permit
smtpd_sasl_auth_enable = yes
broken_sasl_auth_clients = yes
#smtpd_sasl_path = /etc/postfix/sasl:/usr/lib/sasl2
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain=
Open /etc/init.d/postfix, search for the FILES variable and add etc/postfix/sasl/smtpd.conf to the list:
FILES="etc/localtime etc/services etc/resolv.conf etc/hosts \ etc/nsswitch.conf etc/nss_mdns.config etc/postfix/sasl/smtpd.conf"
Restart Postfix and start saslauthd:
# /etc/init.d/postfix restart
# /etc/init.d/saslauthd start
Roundcube setup
sudo apt-get install roundcube
vim /etc/apache2/sites-available/webmail
ServerAdmin webmaster@example.com #change these!
ServerName webmail.example.com
ServerAlias mail.example.com
DocumentRoot /var/www/roundcube
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
ServerSignature Off
ln -s /usr/share/roundcube /var/www/webmail
vim /var/www/webmail/config/main.inc.php
Edit the following
$rcmail_config['default_host'] = 'localhost';
$rcmail_config['virtuser_file'] = '/home/vmail';$rcmail_config['virtuser_query'] = "SELECT username FROM postfix.mailbox WHERE username = '%u'";
No comments:
Post a Comment