Before proceeding with the postfix installation, please make sure,
* The mail server should contain a valid MX record in the DNS server. Navigate to this link how to setup DNS server.
* Firewall and SELinux should be disabled.
#service iptables stop
#vi /etc/selinux/config
and set SELINUX=disabled
Then install postfix via, yum
# yum install postfix
And update your postfix configuration file, /etc/postfix/main.cf
# vi /etc/postfix/main.cf
and change the below values.
myhostname = ns2.example.com ## uncomment and enter your host name
mydomain = example.com ## uncomment and enter your domain name
myorigin = $mydomain ## uncomment
inet_interfaces = all ## change to all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain ## add $domain at the end
mynetworks = 192.168.1.0/24, 127.0.0.0/8 ## uncomment and add your network range
home_mailbox = Maildir/ ## uncomment
Now start the postfix service by,
# service postfix start
and enable postfix auto start at startup by,
# chkconfig postfix on
now the Postfix installation is over. We can test whether it is working fine by sending a test mail.
For that first create a test user called user1.
# useradd user1
# passwd user1
And the incoming mails to this user will be stored in the location /home/user1/Maildir/new
For testing we can use the telnet command, if it is not installed please install telnet via yum,
# yum install telnet
Then enter,
# telnet localhost smtp
Trying ::1...
Connected to localhost.
Escape character is '^]'.
220 ns2.ranjithkr.com ESMTP Postfix
Now please enter,
ehlo localhost
250-ns2.ranjithkr.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
Now enter the below command,
mail from:<user1>
250 2.1.0 Ok
then,
rcpt to:<user1>
250 2.1.5 Ok
and,
data
354 End data with <CR><LF>.<CR><LF>
finally enter the mail body contents,
test
.
250 2.0.0 Ok: queued as D01B1101E0D
and hit quit,
quit
221 2.0.0 Bye
Connection closed by foreign host.
Now check the user1 maildir location and you will be able to see the new mail.
[root@ns2 postfix]# cd /home/user1/Maildir/
[root@ns2 Maildir]# ll
total 12
drwx------. 2 user1 user1 4096 Jun 22 06:18 cur
drwx------. 2 user1 user1 4096 Jun 22 06:18 new
drwx------. 2 user1 user1 4096 Jun 22 06:18 tmp
[root@ns2 Maildir]# cd new/
[root@ns2 new]# ll
total 4
-rw-------. 1 user1 user1 412 Jun 22 06:18 1371862122.Vfd00I3795M419578.ns2.ranjithkr.com
[root@ns2 new]# cat 1371862122.Vfd00I3795M419578.ns2.ranjithkr.com
Return-Path: <user1@ranjithkr.com>
X-Original-To: user1
Delivered-To: user1@ranjithkr.com
Received: from localhost (localhost [IPv6:::1])
by ns2.ranjithkr.com (Postfix) with ESMTP id D01B1101E0D
for <user1>; Sat, 22 Jun 2013 06:17:01 +0530 (IST)
Message-Id: <20130622004822.D01B1101E0D@ns2.ranjithkr.com>
Date: Sat, 22 Jun 2013 06:17:01 +0530 (IST)
From: user1@ranjithkr.com
To: undisclosed-recipients:;
test
[root@ns2 new]#
So postfix works fine now.
* The mail server should contain a valid MX record in the DNS server. Navigate to this link how to setup DNS server.
* Firewall and SELinux should be disabled.
#service iptables stop
#vi /etc/selinux/config
and set SELINUX=disabled
Then install postfix via, yum
# yum install postfix
And update your postfix configuration file, /etc/postfix/main.cf
# vi /etc/postfix/main.cf
and change the below values.
myhostname = ns2.example.com ## uncomment and enter your host name
mydomain = example.com ## uncomment and enter your domain name
myorigin = $mydomain ## uncomment
inet_interfaces = all ## change to all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain ## add $domain at the end
mynetworks = 192.168.1.0/24, 127.0.0.0/8 ## uncomment and add your network range
home_mailbox = Maildir/ ## uncomment
Now start the postfix service by,
# service postfix start
and enable postfix auto start at startup by,
# chkconfig postfix on
now the Postfix installation is over. We can test whether it is working fine by sending a test mail.
For that first create a test user called user1.
# useradd user1
# passwd user1
And the incoming mails to this user will be stored in the location /home/user1/Maildir/new
For testing we can use the telnet command, if it is not installed please install telnet via yum,
# yum install telnet
Then enter,
# telnet localhost smtp
Trying ::1...
Connected to localhost.
Escape character is '^]'.
220 ns2.ranjithkr.com ESMTP Postfix
Now please enter,
ehlo localhost
250-ns2.ranjithkr.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
Now enter the below command,
mail from:<user1>
250 2.1.0 Ok
then,
rcpt to:<user1>
250 2.1.5 Ok
and,
data
354 End data with <CR><LF>.<CR><LF>
finally enter the mail body contents,
test
.
250 2.0.0 Ok: queued as D01B1101E0D
and hit quit,
quit
221 2.0.0 Bye
Connection closed by foreign host.
Now check the user1 maildir location and you will be able to see the new mail.
[root@ns2 postfix]# cd /home/user1/Maildir/
[root@ns2 Maildir]# ll
total 12
drwx------. 2 user1 user1 4096 Jun 22 06:18 cur
drwx------. 2 user1 user1 4096 Jun 22 06:18 new
drwx------. 2 user1 user1 4096 Jun 22 06:18 tmp
[root@ns2 Maildir]# cd new/
[root@ns2 new]# ll
total 4
-rw-------. 1 user1 user1 412 Jun 22 06:18 1371862122.Vfd00I3795M419578.ns2.ranjithkr.com
[root@ns2 new]# cat 1371862122.Vfd00I3795M419578.ns2.ranjithkr.com
Return-Path: <user1@ranjithkr.com>
X-Original-To: user1
Delivered-To: user1@ranjithkr.com
Received: from localhost (localhost [IPv6:::1])
by ns2.ranjithkr.com (Postfix) with ESMTP id D01B1101E0D
for <user1>; Sat, 22 Jun 2013 06:17:01 +0530 (IST)
Message-Id: <20130622004822.D01B1101E0D@ns2.ranjithkr.com>
Date: Sat, 22 Jun 2013 06:17:01 +0530 (IST)
From: user1@ranjithkr.com
To: undisclosed-recipients:;
test
[root@ns2 new]#
So postfix works fine now.
No comments:
Post a Comment