April 2024
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
2930  

Categories

April 2024
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
2930  

Postfix on CentOS 6.4


MAIL SERVERSETUP USING POSTFIX ON CENTOS 6.4

Part 1 MTA Postfix

  • Chapter 1 Email Service
  • Chapter 2 Mail Transfer Agents
  • Chapter 3 Installation and Startup
  • Chapter 4 Postfix Configuration

Part 2 IMAP & POP3 Server

  • Chapter 5 IMAP and POP3 on Dovecot
  • Chapter 6 MUA Configuration

Part 3 Postfix aliases & access control

  • Chapter 7 Postfix Aliases
  • Chapter 8 Postfix Access Control
  • Chapter 9 Postfix Mailing List using Mailman

Part 4 Postfix Authentication

  • Chapter 10 Postfix Authentication using SASL
  • Chapter 11 Postfix Mail Encryption using SSL/TLS

Part 5 Postfix security

  • Chapter 12 Postfix Antispam
  • Chapter 13 Postfix Antivirus

Part 6 Postfix Extended Features

  • Chapter 14 Postfix Backup mail server (Queuing Server)
  • Chapter 15 Squirrelmail as a webmail
  • Chapter 16 Postfix Admin with MySQL

Mail Server Testing Environment

 1.sever.chul.com: 192.168.80.5

Postfix Mail  server (ms1.chul.com)

MUA – Evolution

 2.client.chul.com: 192.168.80.6

Linux mail client

MUA – Thunderbird

Postfix Backup Mail server (ms2.chul.com)

  1. Windows 7

Mail client using MS Outlook 2010

Chapter 1 Email Service

E-mail System Components

1.Mail User Agent (MUA):

A client used to compose and read e-mail (Outlook, Evolution, Thunderbird, Mutt)

2.Mail Transfer Agent (MTA):

An SMTP server used to relay or accept e-mail for delivery (Postfix, Sendmail, Exim, Qmail, Exchange server)

3.Mail Delivery Agent (MDA):

A program used by the final MTA to deliver e-mail to the message store

May be included with the MTA or a separate program such as procmail

4.Mail Access Agent (MAA):

An IMAP/POP3 server used by an MUA to access the message store (Dovecot, Cyrus IMAP)

Chapter 2 Mail Transfer Agents

Agent Description
Sendmail Sendmail mail transfer agent, popular but insecure, complicated to configurewww.sendmail.com
Postfix Fast, easy to configure, and secure mail transfer agent compatible with Sendmail and designed to replace itwww.postfix.org
Qmail Fast, flexible, and secure MTA with its own implementation and competitive with Postfixwww.qmail.org
Exim MTA based on smail3www.exim.org

Chapter 3  Installation and startup

  1. Package installation

l  postfix-2.6.6-2.2.el6_1.i686

  1. Service startup and main directory

# service sendmail stop

# service postfix start

# ls –l /etc/postfix

  1. Service startup checking

# ps –ef | grep postfix

# netstat –nat | grep 25

  1. Runlevel registration

# chkconfig  postfix on

# chkconfig –list postfix

  1. Testing on command

# telnet localhost 25

# mail –v –s ‘testing mail’  linux@chul.com < /etc/passwd

Chapter 4  Postfix Configuration

  1. How to use postconf
  2. postconf can display or edit /etc/postifx/main.cf settings
  3. postconf : Display all settings including defaults:
  4. postconf –n : Display changes from default settings:
  5. Modify current main.cf: postconf -e ‘parameter=value‘

# postconf -e mynetworks_style=subnet

  1. Much simpler than editing /etc/mail/sendmail.cf
  2. Postfix Daemons – /etc/postfix/master.cf
  3. master: postfix master process, runs Postfix daemons on demand
  4. smtpd: postfix smtp server, accepts network connection requests and performs zero or more SMTP transactions per  connection
  5. pickup: Postfix local mail pickup, waits for hints that new mail has been

dropped into the ‘maildrop’ directory, and  feeds  it  into  the ‘cleanup’  daemon.

  1. qmgr: postfix queue manager, awaits the arrival of incoming mail and

arranges for its delivery via Postfix delivery processes.

  1. Postfix: Accepting Inbound E-mail
  2. listen on port 25/tcp on all IP addresses

inet_interfaces = all

  1. include all domains/hosts for which we accept local delivery

myhostname = server.chul.com

mydomain = chul.com

mydestination = $myhostname, $mydomain, jeong.com, localhost

  1. Postfix: Outbound SMTP Relay
  2. To relay e-mail sent by hosts on your internal network to the Internet:

inet_interfaces = all

  1. To include all internal nets or hosts for which it will relay

mynetworks = 127.0.0.0/8  192.168.80.0/24

mynetworks_style = subnet

  1. Postfix: Masquerading
  2. Causes MTA to modify the envelope & headers of an outbound e-mail message
  3. Reduces the number of MX records and hosts/domains to be listed in mydestination

myorigin = chul.com

masquerade_exceptions = root

  1. Postfix Operation
  2. always_bcc = address : Writes all messages
  3. postqueue –p : Displays status of the mail queues
  4. postqueue –f : Attempts to immediately deliver all queued mail
  5. tail -f /var/log/maillog : Watch the mail log update in real time
  6. Testing mail sending and receiving using domains

Chapter 5 IMAP and POP3 on Dovecot

1.Dovecot supports POP3, POP3s, IMAP, and IMAPs

# yum -y install dovecot

  1. # vi /etc/dovecot/dovecot.conf
  • protocols = imap pop3
  • listen = *
  1. # vi /etc/dovecot/conf.d/10-auth.conf
  • disable_plaintext_auth = no
  • auth_mechanisms = plain login
  1. # vi /etc/dovecot/conf.d/10-mail.conf
  • mail_location = maildir:~/Maildir
  1. # vi /etc/dovecot/conf.d/10-master.conf
  • unix_listener auth-userdb {
  • mode = 0600
  • user = postfix
  • group = postfix
  • }

# service dovecot start

# chkconfig dovecot on

  1. Testing dovecot

# telnet localhost 110

# telnet localhost 143

Chapter 6 MUA Configuration

1.Graphical:

l  Evolution on Server system of Linux for POP3

# yum install evolution

user is tland@chul.com

l  Thunderbird on Client system of Linux for IMAP

# yum install thunderbird

user is admin@chul.com

l  Outlook 2010 on Client system of Windows 7 for IMAP

user is jeong@chul.com

2.Text-mode: Mutt and Fetchmail

# mutt -f pop://user@server

# mutt -f pops://user@server

Chapter 7 Postfix Aliases

  1. Postfix Aliases

1) Local Aliases –  mail forwarding

2) Virtual Aliases – Incoming and Outgoing Aliases

2.1) Incoming Aliases for Multiple domains (jeong.com, linux.com)

  1. Virtual Alias Domains – Virtual domains using Linux system accounts
  2. Virtual Mailbox Domains – Virtual domains using non-Linux accounts
  3. Virtual Mailbox Domains using Database such as MySQL and LDAP

– Virtual domains and user mapping using Database

2.2) Outgoing Aliases – change sender’s mail address to receiver (Masquerading)

  1. Postfix Local Aliases (/etc/aliases)
  2. /etc/aliases contains alias maps

postmaster:            root

admin:               tland@chul.com

alist:               kim,itc,dara,tland

tland:             linux,jeong

  1. Using aliases

# vi /etc/postfix/main.cf

alias_maps = hash:/etc/aliases

# newaliases    or    service postfix restart

# ls –l /etc/aliases*

3.Incoming Virtual Aliases

3.1 Virtual Alias Domains – multiple domains using system accounts

  1. Check /etc/postfix/master.cf

virtual   unix  –       n       n       –       –       virtual

  1. Add two alias domains to /etc/postfix/main.cf

virtual_alias_domains = jeong.com, linux.com

virtual_alias_maps = hash:/etc/postfix/virtual

  1. Create virtual mapping to /etc/postfix/virtual

admin@jeong.com       admin

info@jeong.com                  jeong

admin@linux.com                  linux

info@linux.com                          itc

@jeong.com                   catchall              //user unknown

@linux.com                   catchall              //user unknown

  1. File hash

# postmap /etc/postfix/virtual; ls –l /etc/postfix/virtual*

# service postfix restart

3.2 Virtual Mailbox Domains – multiple domains with non-Linux accounts

  1. Check /etc/postfix/master.cf

virtual   unix  –       n       n       –       –       virtual

  1. Add two alias domains to /etc/postfix/main.cf

virtual_mailbox_domains = jeong.com, linux.com

virtual_mailbox_base = /var/spool/mailbox

virtual_mailbox_maps = hash:/etc/postfix/vmailbox

virtual_uid_maps = static:1000

virtual_gid_maps = static:1000

  1. Create virtual mapping to /etc/postfix/vmailbox

admin@jeong.com                    jeong.com/admin

info@jeong.com                  jeong.com/info

admin@linux.com                  linux.com/admin

info@linux.com                          linux.com/info

@jeong.com                                jeong.com/catchall

@linux.com                                linux.com/catchall

  1. Create User and Directory and File hashing

# useradd –u 1000 vuser

# mkdir –p /var/spool/vmailbox/jeong.com    linux.com

# chown vuser.vuser /var/spool/vmailbox; chmod 700 /var/spool/vmailbox

# postmap /etc/postfix/vmailbox; ls –l /etc/postfix/vmailbox*

# service postfix restart

3.3 Virtual Mailbox Domains using Database like MySQL

  1. Checking Postfix for MySQL Map Support

# postconf –m

  1. Configuring Database

Create db, table and users on MySQL

  1. Configuring Postfix to Use the Database

# vi /etc/postfix/main.cf

virtual_mailbox_domains = mysql:/etc/postfix/sql/virtual_mailbox_domains.cf

virtual_uid_maps = mysql:/etc/postfix/sql/virtual_uid_maps.cf

virtual_gid_maps = mysql:/etc/postfix/sql/virtual_gid_maps.cf

virtual_mailbox_maps = mysql:/etc/postfix/sql/virtual_mailbox_recipients.cf

virtual_alias_maps = mysql:/etc/postfix/sql/virtual_alias_maps.cf

# mkdir /etc/postfix/sql

# service postfix restart

  1. Postfix Outgoing Aliases (/etc/postfix/generic)
  2. Activate outgoing aliases in /etc/postfix/main.cf

smtp_generic_maps = hash:/etc/postfix/generic

  1. Creating table in /etc/postfix/generic

root@server.chul.com                 admin@chul.com

linux@chul.com                                       linux@jeong.com

  1. Save and close the file. Create or update generic postfix table

# postmap /etc/postfix/generic

  1. Restart postfix

# service postfix restart

  1. Alias Testing
  2. Local aliases
  3. Incoming virtual alias testing – virtual domains and virtual box
  4. Outgoing virtual alias testing using MTA such as gmail, naver and yahoo

Chapter 8  Postfix Access Control

  1. Activate access control in /etc/postfix/main.cf

smtpd_client_restrictions =

check_client_access hash:/etc/postfix/access

  1. Creating access file format in /etc/postfix/access

1.2.3                                                      REJECT

192.168.80.0                              OK

admin@spammer.com                 OK

server.spammer.com                    REJECT

chul.com                                      OK

  1. Creating Hash file

# postmap  /etc/postfix/access

# service postfix restart

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>