读书人

Postfix装配脚本

发布时间: 2012-08-16 12:02:15 作者: rapoo

Postfix安装脚本

以下脚本在CentOS 5 上通过

?

#!/bin/bash# 切换到root开始安装su -mkdir /data/Downloads/chmod -R 777 /data/Downloads/cd /data/Downloads/wget http://postfix.it-austria.net/releases/official/postfix-2.7.1.tar.gzwget ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/cyrus-sasl-2.1.23.tar.gzwget ftp://ftp.andrew.cmu.edu/pub/cyrus/cyrus-imapd-2.3.16.tar.gzwget http://www.openssl.org/source/openssl-1.0.0a.tar.gz#创建用户useradd -M -s /bin/false -p* postfixgroupadd postdrop# 安装tar xzf openssl-1.0.0a.tar.gzcd openssl-1.0.0a./config --prefix=/usr/local/openssl-1.0.0a  shared threads  # -fPIC for 64 bit OSmakemake installln -s /usr/local/openssl-1.0.0a /usr/local/openssltar xzf cyrus-sasl-2.1.23.tar.gzcd cyrus-sasl-2.1.23./configure --prefix=/usr/local/postfix/cyrus-sasl-2.1.23 \        --enable-login --enable-ntlmmake && make installcd ..tar xzf cyrus-imapd-2.3.16.tar.gzcd cyrus-imapd-2.3.16./configure --prefix=/usr/local/postfix/cyrus-imapd-2.3.16 --with-lock=fcntl \        --with-sasl=/usr/local/postfix/cyrus-sasl-2.1.23 \        --with-openssl=/usr/local/opensslmake && make installcd ..tar xzf postfix-2.7.1.tar.gzcd postfix-2.7.1make makefiles --always-make CCARGS='-I/usr/local/postfix/cyrus-sasl-2.1.23/include/sasl -I/usr/local/openssl/include -DDEF_CONFIG_DIR=\"/usr/local/postfix/etc\" -DFD_SETSIZE=2048 -DUSE_CYRUS_SASL -DUSE_TLS' \        AUXLIBS='-L/usr/local/postfix/cyrus-sasl-2.1.23/lib/sasl2 -L/usr/local/openssl/lib -L/usr/local/openssl/lib64 -lsasl2 -lssl -lcrypto'makemake install#安装过程中需要回答问题,下面三个问题,请使用右边的回答,其他直接按回车用默认值#  [/usr/bin/mailq]   /usr/bin/mailq.postfix#  [/usr/bin/newaliases]   /usr/bin/newaliases.postfix#  [/usr/sbin/sendmail]   /usr/sbin/sendmail.postfixcd ..# 添加以下内容到main.cf echo [BELOW TEXT] >> /usr/local/postfix/etc/main.cflocal_recipient_maps =#请将所有的mail.example.com和example.com替换为您的MX域名###############postfix#################################myhostname = mail.example.commyorigin = example.commydomain = example.comappend_dot_mydomain = nomydestination = $myhostname, localhost.$mydomain, localhost, $mydomain#mynetworks = 192.168.1.0/24, 10.0.0.0/24, 127.0.0.0/8mynetworks = 127.0.0.1  #只接收本机的本地邮件#body_checks = regexp:/usr/local/postfix/etc/body_checks  #用于从邮件中提取信息记录到postfix日志############################CYRUS-SASL############################broken_sasl_auth_clients = yessmtpd_recipient_restrictions=permit_mynetworks,permit_sasl_authenticated,reject_invalid_hostname,reject_non_fqdn_hostname,reject_unknown_sender_domain,reject_non_fqdn_sender,reject_non_fqdn_recipient,reject_unknown_recipient_domain,reject_unauth_pipelining,reject_unauth_destinationsmtpd_sasl_auth_enable = yessmtpd_sasl_local_domain = $myhostnamesmtpd_sasl_security_options = noanonymoussmtpd_sasl_application_name = smtpdsmtpd_banner = Welcome to our $myhostname ESMTP,Warning: Version not Available!# echo [BELOW TEXT] > /usr/local/postfix/etc/smtpd.confecho "pwcheck_method: saslauthd" >> /usr/local/postfix/etc/smtpd.confecho "mech_list: PLAIN LOGIN" >> /usr/local/postfix/etc/smtpd.conf# echo [BELOW TEXT] >> /usr/local/postfix/etc/body_checks/\/account\/([a-z_]+)\/veri/  WARN "$1"/verify=3D([0-9a-f]+)/  WARN "$1"# 设置rm -f /usr/sbin/sendmailln -s /usr/sbin/sendmail.postfix /usr/sbin/sendmailrm -f /etc/alternatives/mtaln -s /usr/sbin/sendmail.postfix /etc/alternatives/mtarm -f /usr/sbin/saslauthdln -s /usr/local/postfix/cyrus-sasl-2.1.23/sbin/saslauthd /usr/sbin/saslauthdrm -rf /etc/postfixln -s /usr/local/postfix/etc /etc/postfix# 启动/etc/rc.d/init.d/sendmail stopchkconfig sendmail offchkconfig --list sendmailchkconfig saslauthd onchkconfig --list saslauthd/etc/rc.d/init.d/saslauthd startpostfix start# 测试,收件人为who@where.comtelnet localhost 25EHLO mail.example.comMAIL FROM:admin@example.comRCPT TO:who@where.com NOTIFY=success,failureDATAsubject:Mail test!This is just a mail test!!!.#从日志中统计退回、拒收、超时失败的邮件#grep "status=bounced" /var/log/maillog | gawk 'match($0,/to=<(.*)>/){print substr($0,RSTART+4,RLENGTH-5)}'#grep "status=deferred" /var/log/maillog | gawk 'match($0,/to=<(.*)>/){print substr($0,RSTART+4,RLENGTH-5)}'#grep "status=expired" /var/log/maillog | gawk 'match($0,/to=<(.*)>/){print substr($0,RSTART+4,RLENGTH-5)}'
?

读书人网 >操作系统

热点推荐