Install MySQL

Install  MySQL :

# apt-get install mysql-server-5.1 mysql-client-5.1

Reading package lists… Done
Building dependency tree
Reading state information… Done
The following extra packages will be installed:
bsd-mailx libdbd-mysql-perl libdbi-perl libhtml-template-perl
libmysqlclient15off libmysqlclient16 libnet-daemon-perl libplrpc-perl mailx
mysql-common postfix ssl-cert
Suggested packages:
dbishell libipc-sharedcache-perl tinyca procmail postfix-mysql postfix-pgsql
postfix-ldap postfix-pcre sasl2-bin resolvconf postfix-cdb mail-reader
The following NEW packages will be installed:
bsd-mailx libdbd-mysql-perl libdbi-perl libhtml-template-perl
libmysqlclient15off libmysqlclient16 libnet-daemon-perl libplrpc-perl mailx
mysql-client-5.1 mysql-common mysql-server-5.1 postfix ssl-cert
0 upgraded, 14 newly installed, 0 to remove and 0 not upgraded.
Need to get 25.4MB of archives.
After this operation, 59.6MB of additional disk space will be used.
Do you want to continue [Y/n]?

Press ‘Y‘ and let installation process begin till end.

Checking if mysql running :

# ps ax | grep mysql

4260 ?        S<     0:00 /bin/sh /usr/bin/mysqld_safe
4376 ?        S<l    0:00 /usr/sbin/mysqld –basedir=/usr –datadir=/var/lib/mysql –user=mysql –log-error=/var/lib/mysql/mail.err –pid-file=/var/run/mysqld/mysqld.pid –socket=/var/run/mysqld/mysqld.sock –port=3306
4797 pts/0    S<+    0:00 grep mysql

Login :

# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 38
Server version: 5.1.31-1ubuntu2 (Ubuntu)

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql> exit
Bye
#

Incoming search terms for the article:

  • libmysqlclient15off centos
  • ubuntu libmysqlclient15off
  • install libmysqlclient15off
  • libmysqlclient15off ubuntu 10
  • libmysqlclient15off
  • libmysqlclient15off ubuntu
  • centos libmysqlclient15off
  • tinyca mysql
  • “bsd-mailx” ubuntu

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

Incoming search terms for the article:

  • linux email server setup lab
  • postfix lab setup
  • postfix_2 5 5 orig tar gz

Install dovecot

Install :

# apt-get install dovecot-postfix

Create SSL/TLS certificate for secure connections :

# cd  /etc/ssl/

# mkdir -p dovecot

# cd /etc/ssl/dovecot/

# openssl req -new -x509 -nodes -out cert.pem -keyout key.pem -days 365

Generating a 1024 bit RSA private key
………………..++++++
………++++++
writing new private key to ‘key.pem’
—–
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter ‘.’, the field will be left blank.
—–
Country Name (2 letter code) [AU]:ID
State or Province Name (full name) [Some-State]:SumSel
Locality Name (eg, city) []:Palembang
Organization Name (eg, company) [Internet Widgits Pty Ltd]:DigitalFusi
Organizational Unit Name (eg, section) []:DigitalFusi
Common Name (eg, YOUR name) []:DigitalFusi
Email Address []:alamster@gmail.com

#

(Edit BOLD data with your own)

Edit /etc/dovecot/dovecot.conf  file:

Find and edit the RED text.

protocols = imap imaps pop3 pop3s
disable_plaintext_auth = no
ssl_disable = no
ssl_cert_file = /etc/ssl/dovecot/cert.pem
ssl_key_file = /etc/ssl/dovecot/key.pem
login_greeting = DigitalFusi Mail Server Ready.
mail_location = maildir:/usr/local/virtual/%d/%n
first_valid_uid = 109
last_valid_uid = 109
first_valid_gid = 117
last_valid_gid = 117
protocol imap {
mail_plugins = quota imap_quota
}
protocol pop3 {
mail_plugins = quota
}
protocol lda {
postmaster_address = postmaster@digitalfusi.com
}
auth default {
mechanisms = plain login
# passdb pam {

# args = session=yes dovecot

# }
passdb sql {
args = /etc/dovecot/dovecot-sql.conf
}
# userdb passwd {
# }
userdb sql {
args = /etc/dovecot/dovecot-sql.conf
}
socket listen {
client {
path = /var/spool/postfix/private/dovecot-auth
mode = 0660
user = postfix
group = postfix
}
}
}

Tips :

Find uid and guid of postfix:

# cat  /etc/passwd | grep postfix

postfix:x:109:117::/var/spool/postfix:/bin/false

Turn On auth for debugging purpose.

Uncomment these lines :

auth_verbose = yes

auth_debug = yes

auth_debug_passwords = yes

Edit /etc/dovecot/dovecot-sql.conf file:
You can either copy this file or edit your own file to match.

# echo ‘ ‘ > /etc/dovecot/dovecot-sql.conf

driver = mysql
connect = host=localhost dbname=postfix user=postfix password=postfixjaunty
default_pass_scheme = MD5
password_query = SELECT password FROM mailbox WHERE username = ‘%u’
user_query = SELECT maildir, 109 AS uid, 117 AS gid, CONCAT(‘maildir:storage=’, FLOOR( quota / 1024 ) ) AS quota FROM mailbox WHERE username = ‘%u’ AND active = ‘1

Restart dovecot :

# /etc/init.d/dovecot restart

Remember : 109 and 117 depend on previous step.

Incoming search terms for the article:

  • apt get install dovecot-postfix

Hello world!

Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!

  • Pages

  • Download Ubuntu

  • Download Fedora

  • Tags

  • Categories

    • Translate to:

  •