#!/bin/bash # ToDo # configure antivirus # configure antispam # configure secure connections # # configure timezone and locale # dpkg-reconfigure tzdata locale-gen de_DE # # POSTFIX # # pre-configure debconf-set-selections <<\EOF postfix postfix/mailname string mx postfix postfix/main_mailer_type select Internet Site EOF # install apt-get install -y postfix # post-configure cp /etc/postfix/main.cf /etc/postfix/main.cf.$(date -I) postconf -e 'myhostname = YOUR_DOMAIN.com' postconf -e 'relayhost = smtp.YOUR_PROVIDER.com' postconf -e 'smtp_sasl_security_options = noanonymous' postconf -e 'smtp_sasl_password_maps = hash:/etc/postfix/sasl_password' postconf -e 'smtp_sasl_auth_enable = yes' postconf -e 'message_size_limit = 0' # configure smtp cp /mnt/etc/postfix/sasl_password /etc/postfix/ postmap /etc/postfix/sasl_password # restart /etc/init.d/postfix restart # # DOVECOT (imap server) # apt-get install -y dovecot-imapd cp /etc/dovecot/dovecot.conf /etc/dovecot/dovecot.conf.$(date -I) sed -i 's|#disable_plaintext_auth = yes|disable_plaintext_auth = no|g' /etc/dovecot/dovecot.conf /etc/init.d/dovecot restart # # SASL # # install apt-get install -y sasl2-bin # post-configure cp /etc/default/saslauthd /etc/default/saslauthd.$(date -I) sed -i 's|START=no|START=yes|g' /etc/default/saslauthd sed -i 's|OPTIONS="-c -m /var/run/saslauthd"|OPTIONS="-c -m /var/spool/postfix/var/run/saslauthd"|g' /etc/default/saslauthd cat <<EOF> /etc/postfix/sasl/smtpd.conf pwcheck_method: saslauthd mech_list: PLAIN LOGIN EOF postconf -e 'smtpd_sasl_auth_enable = yes' postconf -e 'smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination' postconf -e 'broken_sasl_auth_clients = yes' # add user adduser postfix sasl # restart /etc/init.d/saslauthd restart /etc/init.d/postfix restart # # MAILDROP # # install apt-get install -y maildrop # post-configure cp /etc/maildroprc /etc/maildroprc.$(date -I) sed -i 's|#DEFAULT="$HOME/Maildir"|DEFAULT="$HOME/Maildir"|g' /etc/maildroprc postconf -e 'mailbox_command = /usr/bin/maildrop -d ${USER}' # restart /etc/init.d/postfix restart # # FETCHMAIL # # insall apt-get install -y fetchmail # post-configure cp /etc/default/fetchmail /etc/default/fetchmail.$(date -I) sed -i 's|START_DAEMON=no|START_DAEMON=yes|g' /etc/default/fetchmail cp /etc/fetchmailrc /etc/fetchmailrc.$(date -I) cp /mnt/etc/fetchmailrc /etc/ chown fetchmail /etc/fetchmailrc # restart /etc/init.d/fetchmail restart # # amavisd-new # apt-get install -y amavisd-new spamassassin clamav clamav-daemon unzip libnet-ph-perl libnet-snpp-perl libnet-telnet-perl nomarch lzop unrar-free ripole unrar-free bzip2 cp /etc/amavis/conf.d/15-content_filter_mode /etc/amavis/conf.d/15-content_filter_mode.$(date -I) # configure sed -i 's|#@bypass|@bypass|g' /etc/amavis/conf.d/15-content_filter_mode sed -i 's|# \\%bypass| \\%bypass|g' /etc/amavis/conf.d/15-content_filter_mode cp /etc/amavis/conf.d/20-debian_defaults /etc/amavis/conf.d/20-debian_defaults.$(date -I) adduser clamav amavis /etc/init.d/amavis restart /etc/init.d/clamav-daemon restart # cp /etc/clamav/freshclam.conf /etc/clamav/freshclam.conf.$(date -I) /etc/init.d/clamav-freshclam restart postconf -e 'content_filter = amavis:[127.0.0.1]:10024' postconf -e 'receive_override_options = no_address_mappings' cp /etc/postfix/master.cf /etc/postfix/master.cf.$(date -I) cat <<EOF>> /etc/postfix/master.cf amavis unix - - - - 2 smtp -o smtp_data_done_timeout=1200 -o smtp_send_xforward_command=yes 127.0.0.1:10025 inet n - - - - smtpd -o content_filter= -o local_recipient_maps= -o relay_recipient_maps= -o smtpd_restriction_classes= -o smtpd_client_restrictions= -o smtpd_helo_restrictions= -o smtpd_sender_restrictions= -o smtpd_recipient_restrictions=permit_mynetworks,reject -o mynetworks=127.0.0.0/8 -o strict_rfc821_envelopes=yes -o receive_override_options=no_unknown_recipient_checks,no_header_body_checks -o smtpd_bind_address=127.0.0.1 EOF /etc/init.d/postfix restart apt-get install -y razor pyzor #??dcc-client cp /etc/spamassassin/local.cf /etc/spamassassin/local.cf.$(date -I) sed -i 's|# rewrite_header Subject|rewrite_header Subject|g' /etc/spamassassin/local.cf sed -i 's|# use_bayes 1|use_bayes 1|g' /etc/spamassassin/local.cf sed -i 's|# bayes_auto_learn 1|bayes_auto_learn 1|g' /etc/spamassassin/local.cf cat <<EOF>> /etc/spamassassin/local.cf #pyzor use_pyzor 1 pyzor_path /usr/bin/pyzor pyzor_add_header 1 #razor use_razor2 1 razor_config /etc/razor/razor-agent.conf #bayes #use_bayes_rules 1 EOF # # COURIER (only if your dont use dovecot) # # pre-configure debconf-set-selections <<\EOF courier-base courier-base/webadmin-configmode boolean false EOF # install apt-get install -y courier-imap # create maildirs maildirmake /etc/skel/Maildir maildirmake /etc/skel/Maildir/.Drafts maildirmake /etc/skel/Maildir/.Sent maildirmake /etc/skel/Maildir/.Trash maildirmake /etc/skel/Maildir/.Templates maildirmake /etc/skel/Maildir/.SPAM # restart /etc/init.d/courier-imap restart # # TEST # # install apt-get install -y mailx # send test mail mail -s "test_$(date)" YOUR_EMAIL < /etc/hosts # view found spam grep SPAM /var/log/syslog # # LINKS # http://www.ubuntu.com/products/whatisubuntu/serveredition/features/mailserver - Ubuntu Features Mail server http://www.howtoforge.de/howto/der-perfekte-server-ubuntu-hardy-heron-ubuntu-804-lts-server/ http://holl.co.at/howto-email/ # mailq http://www.huschi.net/4_277_de.html # fetchmail http://wiki.ubuntuusers.de/Fetchmail # dovecut http://wiki.ubuntuusers.de/Dovecot # sasl http://wiki.ubuntuusers.de/Postfix/Erweiterte_Konfiguration # postfix http://wiki.ubuntuusers.de/Postfix https://help.ubuntu.com/community/Postfix http://www.postfix.org/postconf.5.html # amavisd http://www.howtoforge.de/howto/amavisd-new-in-postfix-zur-spam-und-virus-uberprufung-integrieren/ # test vi /etc/hostname vi mailname vi /etc/amavis/conf.d/05-node_id
Do you like this page? Then support it. Please click the AD below and visit the sponsor. Thank you!