Postfix script configuration
#! /Bin/bash
# This is a email server configure script
POSTFIX =/etc/postfix/mian. cf defines the location of the mail configuration file
DOVECOT =/etc/dovecot. conf defines the mail pop3 configuration file location
POSTFIXMBER = 26 value returned when a syntax error is checked
PROT = $ (lsof-I: 25 | awk 'nr = 2 {print $1} ') defines the process that occupies port 25
Netstat-nl | grep: 25 &>/dev/null check whether port 25 is enabled
If [$? -Eq 0]; then
Pkill-9 $ PROT 25 the occupied process is killed when port is occupied
Else
Echo "25 prot already release"
Fi
ForWRAP in {postfix, dovecot} install the mail server package
Do
Rpm-q $ WRAP &>/dev/null check whether the two packages exist
If [$? ! = 0]; then
Yum-y install $ WRAP
Else
Echo "$ WRAPalready install"
Fi
Done
Echo "myhostname = mail.baidu.com"> $ POSTFIX the Host Name of the email server
Echo "mydomain = baidu.com"> $ POSTFIX
Echo "myorigin = $ mydomain" >>$ POSTFIX the sender's suffix
Echo "inet_interfaces = all"> $ POSTFIX listener Port
Echo "mydistation = $ mydmain" >>$ POSTFIX the sender's DNS suffix
Echo "mynetworks = 0.0.0.0/24"> $ POSTFIX: sets which CIDR blocks are allowed to forward emails to external regions to the postfix.
Echo "mail_spool_directory =/var/spool/mail"> $ POSTFIX: Set the directory where emails are stored.
Postfixcheck check syntax
If [$? -Eq 0]; then
Service postfix restart Enable email service
Chkconfig postfix on
Else
Echo "postfix configure fileappear failed"
Exit $ POSTMBER check the configuration file failed and return the I mail storage effort Value
Fi
Echo "protocols = pop3" >>$ DOVECOT
Echo "listen = *" >>$ DOVECOT
Service dovecot restart
Chkconfig dovecot on
Install and configure the Postfix email service in CentOS 6.4
Install the mail server Postfix in CentOS 5.5
Build a Postfix email server for Red Hat Enterprise Linux 5.4
Postfix (authentication) for secure email servers in Linux)