Wednesday, May 11, 2011

Postfix MTA Configuration

Firstly Lets Introduce with Term POSTFIX:

Postfix:  In computing, Postfix is a free and open-source mail transfer agent (MTA) that routes and delivers electronic mail. It is intended as a fast, easier-to-administer, and secure alternative to the widely-used Sendmail MTA.

Install Postfix:

Make the use of yum or download postfix and install it.

Here I have  installed it using yum. i.e use 

#yum install postfix

 

Configure Postfix:

Go to the main configuration file main.cf in /etc/postfix/ directoy We need to make it listen to network request, accept mails bound to our domain and use maildir which is a better mailbox format than mbox the default. 

Find the following keys and change its values as follows.

inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
home_mailbox = Maildir/

 In main.cf, lines starting with # are comments. Save the file after completing your changes.Make sure that all mail_spool_directory lines are commented out. Otherwise, it will override the setting in the home_mailbox line above.

Now Restart the postfix service.

Sample postfix session. Replace fedora with any valid user account. The dot after the line test is a command that should be typed in.

[root@fedora ~]# telnet localhost smtp
Trying ::1...
Connected to localhost.
Escape character is '^]'.
220 fedora.localdomain ESMTP Postfix
ehlo list
250-fedora.localdomain
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
mail from:fedora
250 2.1.0 Ok
rcpt to:ks
250 2.1.5 Ok
data
354 End data with .
Hi This is the Mail from User *** fedora ** to ks
.
250 2.0.0 Ok: queued as 76BB020509
quit
221 2.0.0 Bye
Connection closed by foreign host.
[root@fedora ~]#
 

To check if the mail indeed exists

[root@fedora ~]# cd /home/ks/Maildir/new/
[root@fedora new]# ls
1305108617.Vfd00I2050eM84839.fedora
[root@fedora new]# vi 1305108617.Vfd00I2050eM84839.fedora
[root@fedora new]# cat 1305108617.Vfd00I2050eM84839.fedora
Return-Path:
X-Original-To: ks
Delivered-To: ks@fedora.localdomain
Received: from list (localhost [IPv6:::1])
        by fedora.localdomain (Postfix) with ESMTP id 76BB020509
        for ; Wed, 11 May 2011 15:39:37 +0530 (IST)
Message-Id: <20110511100949.76BB020509@fedora.localdomain>
Date: Wed, 11 May 2011 15:39:37 +0530 (IST)
From: fedora@fedora.localdomain
To: undisclosed-recipients:;

Hi This is the Mail from User *** fedora ** to ks
[root@fedora new]#

NoteIf you encounter any problems, check the log file at /var/log/maillog.


!Enjoy
Kuldeep Sharma

 

 

3 comments:

Integrate Jenkins with Azure Key Vault

Jenkins has been one of the most used CI/CD tools. For every tool which we are using in our daily life, it becomes really challenges when ...