Installing and setting up Postfix SMTP Server in Red Hat Enterprise Linux 5 or CentOS 5 is easy. Postfix has secure default settings so we just need to open it up a bit.
Install Postfix and Mail Transport Agent Switcher

1. If you did not add postfix and system-switch-mail-gnome during the CentOS installation, you can add it now using Package Manager tool.Switch to Postfix from Sendmail
By default, Sendmail is the active SMTP server. Here’s how to change it.

1. Click System, select Administration, and click Mail Transport Agent Switcher. This will launch the system-switch-mail window.Configure Postfix

1. Click Applications, select System Tools then click File Browser. This will launch the File Browser window.
2. In the Location field, type in /etc/postfix and press Enter. If you don’t see the Location field, click the notepad button to toggle to text-based location bar.
3. Double click on the file main.cf to open it for editing. 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.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.
4. Restart the postfix service. Learn how to restart services here.Test Postfix

1. Click Applications, select Accessories, and click Terminal. This will launch the Terminal window.Sample postfix session. Replace johndoe with any valid user account. The dot after the line test is a command that should be typed in.
If you need to add new user accounts, learn how to add or remove user accounts here.[root@mail ~]# telnet localhost smtp Trying 127.0.0.1… Connected to localhost.localdomain (127.0.0.1). Escape character is ‘^]’. 220 mail.acme.local ESMTP Postfix ehlo host 250-mail.acme.local 250-PIPELINING 250-SIZE 10240000 250-VRFY 250-ETRN 250-ENHANCEDSTATUSCODES 250-8BITMIME 250 DSN mail from: johndoe 250 2.1.0 Ok rcpt to: johndoe 250 2.1.5 Ok data 354 End data with <CR><LF>.<CR><LF> test . 250 2.0.0 Ok: queued as 9729067C17 quit 221 2.0.0 Bye Connection closed by foreign host. [root@mail ~]#
To check if the mail indeed exists
[root@mail ~]# cd /home/johndoe/Maildir/new [root@mail new]# ls 1185669817.Vfd00I18012M795756.mail.acme.local [root@mail new]# cat 1185669817.Vfd00I18012M795756.mail.acme.local
Don’t worry, you don’t have to type in the whole filename above. Just type in the first few characters say 118 then press Tab to activate automatic completion.
From johndoe@mail.acme.local Thu Feb 22 21:48:28 2007
Return-Path: <johndoe@mail.acme.local>
X-Original-To: johndoe
Delivered-To: johndoe@mail.acme.local
Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
by mail.acme.local (Postfix) with SMTP id 9729067C17
for <johndoe>; Thu, 22 Feb 2007 21:48:26 -0500 (EST)
Message-Id: <20070222134827.9729067C17@mail.acme.local>
Date: Thu, 22 Feb 2007 21:48:26 -0500 (EST)
From: johndoe@mail.acme.local
To: undisclosed-recipients:;
test
[root@mail mail]#
If you encounter any problems, check the log file at /var/log/maillog.
Review your Postfix aliases configuration file. There are some predefined email aliases that might conflict with your existing mail accounts like sales, marketing, info, etc.***
Posted on 4/23/2007 and last updated on 7/12/2008
Filed under CentOS 5 , Postfix , Red Hat Enterprise Linux 5
Share This


October 24th, 2007 at 3:47 pm
I have running mailserver with sendmail on REDHAT 9 , i want to chnage it ti PostFix on a CENTOS 5 , what about the UserMailboxes how to keep it
BestRegards
October 26th, 2007 at 2:43 am
Postfix is a drop in replacement for sendmail, thus Postfix can read the UserMailboxes. I do not know your exact mail configuration but assuming you are getting your mail recipients from the Linux user accounts, all you have to do is transfer the user accounts and mailboxes to the new OS.
To transfer the user accounts to the new server, append the user and group into the following files
/etc/group - contains the group accounts
/etc/passwd - contains the user accounts
/etc/shadow - contains the user passwords
To transfer the UserMailboxes, you can use rsync to copy it into the new server.
October 28th, 2007 at 7:34 pm
I used /etc/shadow accounts and my users mail boxes stored in /var/spool/mail for each user name there is just file contain all of his mail here the situation is differ that Psotfix use home_mailbox = Maildir , in this path there a folder and in it each mail for the same users stored as afile ..
October 29th, 2007 at 3:42 am
In your case, comment off the line home_mailbox = Maildir/
Postfix will automatically use mbox the default, which is stored in /var/spool/mail
October 29th, 2007 at 4:38 am
thanks , good for that , Other Questions , is there is another method that control user mailbox size rather tan diskquota .
October 29th, 2007 at 4:41 am
I change my server befor5 year to anothet from rehat8 to 9 and retstor tha mail boxes in the new mail server , but any account who receive the First ew email on the new server his mail box become empty from the prevoius (redhat
mails . ???
October 29th, 2007 at 5:41 am
Disk quota is the only method I know. There are patches for Postfix that supports per user mailbox quota but I have never tried them.
So hows the transfer to CentOS 5, did it work?
October 29th, 2007 at 12:02 pm
I have a hosiptal and it depend on the mail server so i wating untill finishing from testing all thing i need on another pc , when very thing is ok i will do it and tell you
November 5th, 2007 at 5:59 pm
Im kinda new to all this kinda stuff. Im just on the edge of upgrading my desktop PC to CENTOS to function as a mail server. It used to be a windows 98 machine with a 10GB HDD 64
November 5th, 2007 at 5:59 pm
whoops! never finished my reply. Anyways is there anything i should know before i make the leap?
November 5th, 2007 at 10:50 pm
Will the CentOS mail server cover all of your requirements? For me it should have the following
POP3, IMAP and Web Mail
Anti-spam
Anti-virus
Active Directory Integration
Mailbox backup
When I was sure that the CentOS mail server will be able to handle all of those, I made the jump.
December 12th, 2007 at 7:59 am
I m fresher in RHEL fiild
just i come to know about postfix5
January 28th, 2008 at 11:35 pm
I have set winbind and samba and can test users from active directery. I have installed postfix and need it to use the active directly users with winbind.
It was mentioned in another howto that I can be done, but I couldn’t find how?
any Help! thank you
January 29th, 2008 at 12:13 pm
If you have completed the Test the Active Directory Integration, then congratulations, both Postfix and Dovecot can use your Active Directory accounts. There’s no other steps to follow because Winbind makes it appear that the Active Directory accounts are part of Linux. Try it.
March 14th, 2008 at 10:33 am
please help…
I can’t edit main.cf… it i read only…
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
home_mailbox = Maildir/
It does not allow me to edit how im going to change the value of main.cf - READ ONLY file?
thnx
March 14th, 2008 at 3:40 pm
This means you don’t have permission to edit the file. You need to login as root. Another way to edit the file is to launch the terminal window, type in su and type in your root password to enable your terminal session to gain the root permission. Then issue the command gedit /etc/postfix/main.cf.
March 19th, 2008 at 6:06 am
Hi,
We are installed postfix . We aretesting the sending mail to one of the yahoo acccount . We are getting the logs saying that coneection timed out. Could you give me some tips.Thank you
Basu
March 29th, 2008 at 6:23 am
my mail log when im sending to my account in gmail.com
May 29 14:25:44 lhantina postfix/smtp[6861]: 21B4F8D8069: to=, relay=gmail-smtp-in.l.google.com[72.14.253.27]:25, delay=32, delays=29/0.01/1.7/1.4, dsn=2.0.0, status=sent (250 2.0.0 OK 1206771726 m28si3032504poh.13)
May 29 14:25:44 lhantina postfix/qmgr[6395]: 21B4F8D8069: removed
March 29th, 2008 at 6:30 am
It looks like it is normal, what seems to be the problem?
March 29th, 2008 at 6:38 am
Basu,
You probably have connectivity problems, try doing the SMTP Telnet Test from your server machine and connect to yahoo’s mail server at e.mx.mail.yahoo.com.
March 29th, 2008 at 8:56 pm
Hi all,
I’ ve issue after installation of postfix:
I changed my main.cf with
home_mailbox = Maildir/
but, the mail is still stored in
/var/spool/mail
No entry is made within the home directoryy. What did I wrong?
Cheers,
Jan
March 29th, 2008 at 10:22 pm
Comment out all mail_spool_directory lines in main.cf.
April 22nd, 2008 at 12:49 pm
AD, domain users without email seted up, i configured postfix accordig to that material, i can send emails from user1 to user2 (without domain suffix). What shall i do to make possible sending email from user1@local.domain to user2@local.domain and also outside of local.domain? How can i restrict to some users sending emails outside of local.domain to only internal use?
May 5th, 2008 at 4:11 pm
For the Mailbox size and message size limits.
mailbox_size_limit = 0 # 0 = unlimited
message_size_limit = 102400000 # Limits message to this size
Hope that Helps.
May 13th, 2008 at 6:42 am
Dear Sir,
I have setup the CENTOS 5 x64 Postfix mail with only IMAP/SMTP functions, but I am getting weird response when sending test mails to local and gmail.
When I did the test, it response ok
[root@mail spamassassin]# telnet localhost smtp
Trying 127.0.0.1…
Connected to localhost.localdomain (127.0.0.1).
Escape character is ‘^]’.
220 mail.studioclassroom.com ESMTP Postfix
ehlo host
250-mail.studioclassroom.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
mail from: service
250 2.1.0 Ok
rcpt to: service
250 2.1.5 Ok
data
354 End data with .
thie si a stea
.
250 2.0.0 Ok: queued as CD4852BF57B
quit
221 2.0.0 Bye
The mail log seems to be okay also.
But for /home/service/MailDir/new
it’s empty
I am stuck as to where should I be looking for errors….. Please help~~~
Thank you.
May 13 14:37:25 mail postfix/master[13014]: warning: process /usr/libexec/postfix/qmgr pid 14666 exit status 1
May 13 14:37:25 mail postfix/master[13014]: warning: /usr/libexec/postfix/qmgr: bad command startup — throttling
May 13 14:37:35 mail postfix/smtpd[14637]: CD4852BF57B: client=mail.studioclassroom.com[127.0.0.1]
May 13 14:37:42 mail postfix/cleanup[14668]: CD4852BF57B: hold: header Received: from host (mail.studioclassroom.com [127.0.0.1])??by mail.studioclassroom.com (Postfix) with ESMTP id CD4852BF57B??for ; Tue, 13 May 2008 14:37:30 +0800 (CST) from mail.studioclassroom.com[127.0.0.1]; from= to= proto=ESMTP helo=
May 13 14:37:42 mail postfix/cleanup[14668]: CD4852BF57B: message-id=
May 13 14:37:42 mail MailScanner[14531]: New Batch: Scanning 1 messages, 948 bytes
May 13 14:37:42 mail MailScanner[14531]: Expired 1 records from the SpamAssassin cache
May 13 14:37:42 mail MailScanner[14531]: Virus and Content Scanning: Starting
May 13 14:37:42 mail MailScanner[14531]: Requeue: CD4852BF57B.429B2 to 7FFF52BF580
May 13 14:37:42 mail MailScanner[14531]: Uninfected: Delivered 1 messages
May 13 14:37:46 mail postfix/smtpd[14637]: disconnect from mail.studioclassroom.com[127.0.0.1]
May 13th, 2008 at 12:59 pm
Check /var/spool/mail. Your case may be similar to Jan Hedtfed’s case (see his posting above).
May 14th, 2008 at 5:54 am
I have commented out the necessary sections, I am not quite sure if it has anything to do with x64 system because I used the same config files for another x86 machine and it works with some minor glitches….
I have downgraded the x64 machine to a CENTOS4 x86 and it works now. Thank you.
Great Website, saves lots of time when doing this without notes every 5 years…..
June 12th, 2008 at 8:34 am
HELP PLEASE!
cannot send to outside network, but using telnet I can send to my gmail account…
Jun 13 00:25:48 upclap postfix/pickup[3931]: F226F70803E: uid=48 from=
Jun 13 00:25:49 upclap postfix/cleanup[3938]: F226F70803E: message-id=
Jun 13 00:25:49 upclap dovecot: imap-login: Login: user=, method=PLAIN, rip=::ffff:127.0.0.1, lip=::ffff:127.0.0.1, secured
Jun 13 00:25:49 upclap postfix/qmgr[3932]: F226F70803E: from=, size=642, nrcpt=1 (queue active)
Jun 13 00:25:49 upclap dovecot: IMAP(lhan): Disconnected: Logged out
Jun 13 00:25:49 upclap dovecot: imap-login: Login: user=, method=PLAIN, rip=::ffff:127.0.0.1, lip=::ffff:127.0.0.1, secured
Jun 13 00:25:49 upclap dovecot: IMAP(lhan): Disconnected: Logged out
Jun 13 00:25:55 upclap postfix/smtp[3942]: F226F70803E: to=, relay=gmail-smtp-in.l.google.com[209.85.147.114]:25, delay=6.3, delays=0.02/0/0.86/5.4, dsn=5.7.1, status=bounced (host gmail-smtp-in.l.google.com[209.85.147.114] said: 550-5.7.1 [220.255.85.91] The IP you’re using to send mail is not authorized 550-5.7.1 to send email directly to our servers. Please use the SMTP 550-5.7.1 relay at your service provider instead. Learn more at 550 5.7.1 http://mail.google.com/support/bin/answer.py?answer=10336 v39si1364511wah.40 (in reply to end of DATA command))
Jun 13 00:25:55 upclap postfix/cleanup[3938]: 3B58970803F: message-id=
Jun 13 00:25:55 upclap postfix/bounce[3948]: F226F70803E: sender non-delivery notification: 3B58970803F
Jun 13 00:25:55 upclap postfix/qmgr[3932]: 3B58970803F: from=, size=3188, nrcpt=1 (queue active)
Jun 13 00:25:55 upclap postfix/qmgr[3932]: F226F70803E: removed
June 12th, 2008 at 11:03 am
You probably need to setup a reverse DNS to your mail server. Ask your ISP about it, they are the ones who will set it up.
June 18th, 2008 at 9:23 pm
Hi to everybody. I follow all the instruction, it works wery well, I need to use it as SMTP server only, for now, but in the next future I will improve the POP3 use.
This is my question: If I use the same hostname like my site (ex. smtp.sitename.com or better mail.sitename.com) may I encounter any problem about functionality?
If I put in my mail program on workstation, smtp server “mail.sitename.com” when I try to send an email I recive an error, if I put the address of the server it works. Maybe is necessary add on the network DNS server the addres of the mail server or there is another way to do it.
Thanks and congratulation for article.
June 18th, 2008 at 10:13 pm
That’s right, you need to add “mail.sitename.com” to your network DNS. Another option would be to add “mail.sitename.com” to each workstation’s host file but this is not recommended and involves more work.
July 15th, 2008 at 10:08 pm
HELP!!! I have follow all the steps in the MailScanner, Postfix, ClamAV and SpamAssassin Setup Howto for RHEL/CentOS 5 article, but I have a problem in the end when I try to test if postfix is still working…
this is the error:
[root@localhost ~]# telnet localhost smtp
Trying 127.0.0.1…
Connected to localhost.localdomain (127.0.0.1).
Escape character is ‘^]’.
220 localhost.localdomain ESMTP Postfix
ehlo host
250-localhost.localdomain
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
mail from: udla1
452 4.3.1 Insufficient system storage
Please this is for a very important exam!!! HELP!!!
July 21st, 2008 at 1:40 pm
Good morning,
I would like postfix keeps a copy of mail on the server, how?