Installing & Configuring Postfix on RHEL or CentOS

| 0 Comments | 0 TrackBacks

Below is the script I use to install and configure Postfix. My configuration requires that I use a outbound relay host, a smtp server from Postini. In summary, this script will do the following:

  1. Install Postfix
  2. Setup the main.cf configuration file
  3. Setup the virtual configuration file
  4. Execute postmap on the virtual file
  5. Enable Postfix to start upon bootup
  6. Disable Sendmail
  7. Shutdown Sendmail
  8. Startup Postfix



yum install postfix -y

cp /etc/postfix/main.cf /etc/postfix/main.cf.orig
cat > /etc/postfix/main.cf << EOF
myhostname = mail01.srv.domain.com
myorigin = $myhostname
mydestination = $myhostname, localhost.$mydomain, localhost
mynetworks = 192.168.0.0/24

virtual_alias_domains = domain.com domain2.com
virtual_alias_maps = hash:/etc/postfix/virtual

relayhost = outboundsXXX.obsmtp.com # postini

queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
mail_owner = postfix

inet_interfaces = localhost, mail01

unknown_local_recipient_reject_code = 550

alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases

sendmail_path = /usr/sbin/sendmail.postfix
newaliases_path = /usr/bin/newaliases.postfix
mailq_path = /usr/bin/mailq.postfix
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/share/man
sample_directory = /usr/share/doc/postfix-2.3.3/samples
readme_directory = /usr/share/doc/postfix-2.3.3/README_FILES
EOF

cp /etc/postfix/virtual /etc/postfix/virtual.orig
cat > /etc/postfix/virtual << EOF
# postmap /etc/postfix/virtual

postmaster@domain.com user1
user1@domain.com user1
user.one@domain.com user1
@domain.com user1

postmaster@domain2.com user1
@domain2.com user1
EOF

postmap /etc/postfix/virtual

chkconfig --add postfix
chkconfig postfix on
chkconfig sendmail off
service sendmail stop
service postfix restart


No TrackBacks

TrackBack URL: http://baldwinsung.com/cgi-bin/mt-tb.cgi/132

Leave a comment

Recent Entries

Minimal Post Configuration for CentOS
service yum-updatesd stop chkconfig yum-updatesd off service avahi-daemon stop chkconfig avahi-daemon off service bluetooth stop chkconfig bluetooth off service…
15 Central Park West
The Real Deal details the buyers of the wonderful apartments at 15 CPW. http://therealdeal.com/newyork/articles/a-unit-by-unit-look-at-15-cpw http://s3.amazonaws.com/trd_three/images/17726/CPWBinder.pdf…
AJAX Toolkits
Prototype http://prototypejs.org Scriptaculous http://script.aculo.us Dojo http://dojotoolkit.org YUI http://developer.yahoo.com Ext http://extjs.com Sarissa http://sarissa.sf.net Mochikit http://mochikit.com jQuery http://jquery.com MooTools http://mootools.net GWT…