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:
- Install Postfix
- Setup the main.cf configuration file
- Setup the virtual configuration file
- Execute postmap on the virtual file
- Enable Postfix to start upon bootup
- Disable Sendmail
- Shutdown Sendmail
- 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
Leave a comment