1. Install Postfix
=================================
yum install postfix
=================================
2. Install Dovecot
==================================
yum install dovecot
==================================
3. Remove Sendmail
==================================
yum remove sendmail
==================================
4. Enable Postfix & Dovecot on start up
==================================
chkconfig postfix on
chkconfig dovecot on
==================================
5. Configure Postfix
Postfix main configuration files are given below.
5.1 Configure main.cf
Open /etc/postfix/main.cf in an editor and make changes as explained below.
5.1.1 Set host name of the system.
=============================================
myhostname = mail.mailserver.com
=============================================
5.1.2 Set primary domain name of the server.
==================================
mydomain = mailserver.com
==================================
5.1.3 Specify source domain of locally generated emails
================================
myorigin = $myhostname
================================
5.1.4 Specify postfix listening interfaces
==================================
inet_interfaces = all
==================================
5.1.5 Add list of locally hosted domains
=========================================================================================
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain, mail.$mydomain, www.$mydomain, ftp.$mydomain
=========================================================================================
5.1.6 Add relay permitted IP addresses
===================================================
mynetworks = 127.0.0.0/8
===================================================
5.1.7 Add relay permitted IP addresses
Specify "mynetworks_style = host" since Postfix should "trust" only the local machine.
===================================================
mynetworks_style = host
===================================================
5.1.8 Add relay permitted domains.
This should be kept as blank.
==========================
relay_domains =
==========================
5.1.9 Configure Maildir as mailbox
================================
home_mailbox = Maildir/
================================
5.2 Configure Aliases
Create a user named "adminmails" to receive all administrator emails.
=================================
useradd adminmails;
=================================
Edit /etc/aliases
=====================================================
# Person who should get root's mail
root: adminmails
postmaster: adminmails
abuse: adminmails
mailer-daemon: adminmails
=====================================================
Create adminmails' maildir
==============================================
su - adminmails
mkdir ~/Maildir
chmod -R 700 ~/Maildir
==============================================
5.3 Configure sendmail soft-links
=================================================================
ln -s /usr/sbin/sendmail.postfix /usr/sbin/sendmail
ln -s /usr/lib/sendmail.postfix /usr/lib/sendmail
=================================================================
6. Adding a user
6.1 Creating the user
=========================
useradd testusr
=========================
6.2 Setting password for the user
================================
passwd testusr
================================
6.3 Creating Maildir
========================================
su - testusr
mkdir ~/Maildir
chmod -R 700 ~/Maildir
========================================
7. Configure postfix as default mail server
7.1 Install system-switch-mail
============================================================
yum install system-switch-mail
============================================================
Now, run system-switch-mail command to configure postfix as default mail server
8. Start Postfix & Dovecot
============================================
/etc/init.d/postfix start
/etc/init.d/dovecot start
============================================
9. Setting up virtual domains
9.1 Setup email domain in /etc/postfix/virtual file
To setup virtual domains, we need to add domains & email addresses in /etc/postfix/virtual file
Edit /etc/postfix/virtual and add following contents.
===================================================
cptest.org this-text-is-ignored
postmaster@cptest.org postmaster
test1@cptest.org cptest-test1
test2@cptest.org cptest-test2
@cptest.org cptest-test1
====================================================
This will setup the email domain cptest.org and two email addresses test1@cptest.org & test2@cptest.org.
Here, cptest-test1 & cptest-test2 are UNIX users. cptest-test1 is also configured as the catchall address for all cptest.org email addresses.
9.2 Creating the user
=========================
useradd cptest-test1
=========================
9.3 Setting password for the user
================================
passwd cptest-test1
================================
9.4 Creating Maildir
========================================
su - cptest-test1
mkdir ~/Maildir
chmod -R 700 ~/Maildir
========================================
9.5 Configure main.cf to use virtual domains
Edit /etc/postfix/main.cf and add following lines
======================================================================
virtual_alias_maps = hash:/etc/postfix/virtual
======================================================================
9.7 Create postfix virtual domains database
=========================================================
postmap /etc/postfix/virtual
=========================================================
9.8 Reload postfix
===========================================
/etc/init.d/postfix reload
===========================================
=================================
yum install postfix
=================================
2. Install Dovecot
==================================
yum install dovecot
==================================
3. Remove Sendmail
==================================
yum remove sendmail
==================================
4. Enable Postfix & Dovecot on start up
==================================
chkconfig postfix on
chkconfig dovecot on
==================================
5. Configure Postfix
Postfix main configuration files are given below.
- /etc/postfix/main.cf
- /etc/postfix/master.cf
5.1 Configure main.cf
Open /etc/postfix/main.cf in an editor and make changes as explained below.
5.1.1 Set host name of the system.
=============================================
myhostname = mail.mailserver.com
=============================================
5.1.2 Set primary domain name of the server.
==================================
mydomain = mailserver.com
==================================
5.1.3 Specify source domain of locally generated emails
================================
myorigin = $myhostname
================================
5.1.4 Specify postfix listening interfaces
==================================
inet_interfaces = all
==================================
5.1.5 Add list of locally hosted domains
=========================================================================================
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain, mail.$mydomain, www.$mydomain, ftp.$mydomain
=========================================================================================
5.1.6 Add relay permitted IP addresses
===================================================
mynetworks = 127.0.0.0/8
===================================================
5.1.7 Add relay permitted IP addresses
Specify "mynetworks_style = host" since Postfix should "trust" only the local machine.
===================================================
mynetworks_style = host
===================================================
5.1.8 Add relay permitted domains.
This should be kept as blank.
==========================
relay_domains =
==========================
5.1.9 Configure Maildir as mailbox
================================
home_mailbox = Maildir/
================================
5.2 Configure Aliases
Create a user named "adminmails" to receive all administrator emails.
=================================
useradd adminmails;
=================================
Edit /etc/aliases
=====================================================
# Person who should get root's mail
root: adminmails
postmaster: adminmails
abuse: adminmails
mailer-daemon: adminmails
=====================================================
Create adminmails' maildir
==============================================
su - adminmails
mkdir ~/Maildir
chmod -R 700 ~/Maildir
==============================================
5.3 Configure sendmail soft-links
=================================================================
ln -s /usr/sbin/sendmail.postfix /usr/sbin/sendmail
ln -s /usr/lib/sendmail.postfix /usr/lib/sendmail
=================================================================
6. Adding a user
6.1 Creating the user
=========================
useradd testusr
=========================
6.2 Setting password for the user
================================
passwd testusr
================================
6.3 Creating Maildir
========================================
su - testusr
mkdir ~/Maildir
chmod -R 700 ~/Maildir
========================================
7. Configure postfix as default mail server
7.1 Install system-switch-mail
============================================================
yum install system-switch-mail
============================================================
Now, run system-switch-mail command to configure postfix as default mail server
8. Start Postfix & Dovecot
============================================
/etc/init.d/postfix start
/etc/init.d/dovecot start
============================================
9. Setting up virtual domains
9.1 Setup email domain in /etc/postfix/virtual file
To setup virtual domains, we need to add domains & email addresses in /etc/postfix/virtual file
Edit /etc/postfix/virtual and add following contents.
===================================================
cptest.org this-text-is-ignored
postmaster@cptest.org postmaster
test1@cptest.org cptest-test1
test2@cptest.org cptest-test2
@cptest.org cptest-test1
====================================================
This will setup the email domain cptest.org and two email addresses test1@cptest.org & test2@cptest.org.
Here, cptest-test1 & cptest-test2 are UNIX users. cptest-test1 is also configured as the catchall address for all cptest.org email addresses.
9.2 Creating the user
=========================
useradd cptest-test1
=========================
9.3 Setting password for the user
================================
passwd cptest-test1
================================
9.4 Creating Maildir
========================================
su - cptest-test1
mkdir ~/Maildir
chmod -R 700 ~/Maildir
========================================
9.5 Configure main.cf to use virtual domains
Edit /etc/postfix/main.cf and add following lines
======================================================================
virtual_alias_maps = hash:/etc/postfix/virtual
======================================================================
9.7 Create postfix virtual domains database
=========================================================
postmap /etc/postfix/virtual
=========================================================
9.8 Reload postfix
===========================================
/etc/init.d/postfix reload
===========================================
No comments:
Post a Comment