Sendmail Installation

Aus Neobikers Wiki
Zur Navigation springen Zur Suche springen

Vorbereitung

Amavisd-New, Clamav, Spamasassin konfigurieren

Ich benutze hierfür das volatile repository, das habe ich unter /etc/apt/sources.list hinzugefügt:

# debian volatile online quellen
deb     http://volatile.debian.org/debian-volatile etch/volatile main contrib non-free

Nach der Installation muss Amavis die zentrale Spamassassin-Konfigurationsdatei etc/spamassassin/local.cf untergeschoben werden und dem Benutzer clamav die Gruppe amavis zugeordnet werden:

hostname     # these should be correct! (check /etc/hosts /etc/hostname also)
hostname -f  # these should be correct!

apt-get update
aptitude install fetchmail amavisd-new clamav clamav-daemon spamassassin openssl sendmail sasl2-bin host

adduser clamav amavis
mkdir ~amavis/.spamassassin
ln -s /etc/spamassassin/local.cf ~amavis/.spamassassin/user_prefs

Die Amavisd Konfiguration wird angepasst, unter /etc/amavis/conf.d/50-user:

use strict;

#
# Place your configuration directives here.  They will override those in
# earlier files.
#
# See /usr/share/doc/amavisd-new/ for documentation and examples of
# the directives you can use in this file
#

@bypass_virus_checks_maps = (
   \%bypass_virus_checks, \@bypass_virus_checks_acl, \$bypass_virus_checks_re);

@bypass_spam_checks_maps = (
   \%bypass_spam_checks, \@bypass_spam_checks_acl, \$bypass_spam_checks_re);

$final_virus_destiny      = D_DISCARD;  # (data not lost, see virus quarantine)
$final_banned_destiny     = D_DISCARD;  # D_REJECT when front-end MTA
$final_spam_destiny       = D_PASS;
$final_bad_header_destiny = D_PASS;     # False-positive prone (for spam)

#------------ Do not modify anything below this line -------------
1;  # insure a defined return

Amavisd Neustart:

/etc/init.d/amavis restart

fetchmail

Sendmail hat bei mir SPAM-Mail einmal mit einem Error 451: Non existing Sender Domain zurückgewiesen (rejected). Das hatte den Effekt, dass diese Mail in der fetchmail-queue am lokalen Server hängen blieb - sie war ja schon vom Provider abgeholt/gefetched worden. Jetzt versuchte fetchmail dauernd, diese an den lokalen sendmail prozess abzuliefern, der sie hartnäckig immer wieder ablehnt.

Das Problem löste ich, indem ich die antispam Option entsprechend setzte: /etc/fetchmailrc

# Set antispam to -1, since it is far safer to use that together with no
# bouncemail.
#
# antispam 451 together with sendmail (neobiker)
defaults:
  antispam 451
  batchlimit 100

Sendmail-Dual-Konfiguration

Um Amavisd-New mit Spamassassin und Clamav in sendmail zu integrieren verwende ich das Sendmail-Dual Setup (welches der Debian Konfiguration von Exim mit Amavisd-new entspricht).

Auszug aus /usr/share/doc/amavisd-new/README.sendmail-dual.gz:

The following setup is described in this document:

      ............................   ............................
      : sendmail instance MTA-RX :   : sendmail instance MTA-TX :
      :                          :   :                          :
 25 -----> \ (mqueue-rx)         :   : (mqueue)          / -------> forward
587 ----->  > -queue-            :   : -queue-   ->-----+       :
 ^    :    /     | MAIL_HUB,     :   :   |               \ -------> local
 |    :          v SMART_HOST    :   :   ^                      :  delivery
msp   ...........|................   ....|.......................
                 |                       ^ loopback interface
                 v                       | port 10025
 loopback interf.| port 10024            |
            .....|.......................|.............
            : $inet_socket_port=10024    |            :
            :                            |            :
            : $forward_method='smtp:127.0.0.1:10025'  :
            : $notify_method ='smtp:127.0.0.1:10025'  :
            :                                         :
            :    amavisd-new                          :
            ...........................................

Die Sendmail Konfiguration ist unter /etc/mail/sendmail-rx.mc und /etc/mail/sendmail.mc definiert.

Sendmail-RX

/etc/mail/sendmail-rx.mc

include(`/usr/share/sendmail/cf/m4/cf.m4')dnl
VERSIONID(`$Id: sendmail-rx.mc, v 8.13.8-3 2006-12-08 20:21:10 neobiker Exp $')
OSTYPE(`debian')dnl
DOMAIN(`debian-mta')dnl
dnl #
dnl # Items controlled by /etc/mail/sendmail.conf - DO NOT TOUCH HERE
undefine(`confHOST_STATUS_DIRECTORY')dnl        #DAEMON_HOSTSTATS=
dnl # Items controlled by /etc/mail/sendmail.conf - DO NOT TOUCH HERE
dnl #
DAEMON_OPTIONS(`Family=inet, Name=MTA-RX, Port=smtp, Addr=127.0.0.1')dnl
define(`confRUN_AS_USER',`smmta:smmsp')dnl
FEATURE(`access_db', , `skip')dnl
dnl #
dnl FEATURE(`authinfo', `hash /etc/mail/auth/client-info')dnl
dnl define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
dnl #
include(`/etc/mail/sasl/sasl.m4')dnl
include(`/etc/mail/tls/starttls.m4')dnl
dnl #
define(`confPID_FILE', `/var/run/sendmail/mta/sendmail-rx.pid')dnl  Non-default pid file
define(`STATUS_FILE', `/etc/mail/stat-rx')dnl    Non-default stat file
define(`QUEUE_DIR', `/var/spool/mqueue-rx')dnl   Non-default queue area
define(`confQUEUE_SORT_ORDER',`Modification')dnl Modif or Random are reasonable
dnl #
dnl # Match the number of queue runners (R=) to the number of amavisd-new child
dnl # processes ($max_servers). 2 to 7 OK, 10 is plenty, 20 is too many
QUEUE_GROUP(`mqueue', `P=/var/spool/mqueue-rx, R=2, F=f')dnl
dnl #
dnl #
FEATURE(stickyhost)dnl
define(`MAIL_HUB',   `esmtp:[127.0.0.1]')dnl  Forward all local mail to amavisd
define(`SMART_HOST', `esmtp:[127.0.0.1]')dnl  Forward all other mail to amavisd
define(`LOCAL_RELAY',`esmtp:[127.0.0.1]')dnl
define(`confDELIVERY_MODE',`q')dnl     Delivery mode: queue only (a must,
define(`ESMTP_MAILER_ARGS',`TCP $h 10024')dnl  To tcp port 10024 instead of 25
define(`SMTP_MAILER_MAXMSGS',`10')dnl  Max no. of msgs in a single connection
define(`confTO_DATAFINAL',`20m')dnl    20 minute timeout for content checking
MODIFY_MAILER_FLAGS(`ESMTP', `+z')dnl  Speak LMTP (this is optional)
dnl #
MAILER(`smtp')dnl
Sendmail-TX

Folgende Parameter sind anzupassen:

  • define(`SMART_HOST', smtp.1und1.de)dnl
  • MASQUERADE_AS(` Meine-Domain.de ')dnl

/etc/mail/sendmail.mc

define(`_USE_ETC_MAIL_')dnl
include(`/usr/share/sendmail/cf/m4/cf.m4')dnl
VERSIONID(`$Id: sendmail.mc, v 8.13.8-3 2006-12-08 20:21:10 neobiker Exp $')
OSTYPE(`debian')dnl
DOMAIN(`debian-mta')dnl
dnl # Items controlled by /etc/mail/sendmail.conf - DO NOT TOUCH HERE
undefine(`confHOST_STATUS_DIRECTORY')dnl        #DAEMON_HOSTSTATS=
dnl # Items controlled by /etc/mail/sendmail.conf - DO NOT TOUCH HERE
dnl #
DAEMON_OPTIONS(`Family=inet, Name=MTA-TX, Port=10025, Addr=127.0.0.1')dnl
dnl #
define(`SMART_HOST', smtp.1und1.de)dnl
FEATURE(`authinfo', `hash /etc/mail/auth/client-info')dnl
define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
dnl #
dnl FEATURE(`virtusertable')dnl
FEATURE(`use_cw_file')dnl
dnl FEATURE(`access_db', , `skip')dnl
dnl #
include(`/etc/mail/sasl/sasl.m4')dnl
include(`/etc/mail/tls/starttls.m4')dnl
dnl #
include(`/etc/mail/m4/dialup.m4')dnl
include(`/etc/mail/m4/provider.m4')dnl
dnl #
dnl #
dnl # Masquerading options
dnl FEATURE(`always_add_domain')dnl
MASQUERADE_AS(`Meine-Domain.de')dnl
FEATURE(`masquerade_envelope')dnl
dnl MASQUERADE_DOMAIN(`scx.Zuhause.de')dnl
dnl FEATURE(`masquerade_entire_domain')dnl
dnl FEATURE(`allmasquerade')dnl
dnl #
FEATURE(`no_default_msa')dnl
FEATURE(`nocanonify')dnl      Host/domain names are considered canonical
define(`confREFUSE_LA',999)dnl  Disable the feature, limiting belongs to MTA-RX
define(`confMAX_DAEMON_CHILDREN',0)dnl  Disable, limiting belongs to MTA-RX
define(`confSMTP_LOGIN_MSG', `$w.tx.$m Sendmail $v/$Z; $b')dnl
define(`confTO_IDENT', `0')dnl  Disable IDENT
dnl #
dnl #
dnl # Default Mailer setup
MAILER_DEFINITIONS
MAILER(scalix)dnl
MAILER(`local')dnl
MAILER(`smtp')dnl

Sendmail Routing

Lokale Emails (z.B. root) und die Mails meiner externen Mail-Domain (z.B. ich@neobiker.de) sollen nicht an den Smarthost gesendet werden, sondern lokal an den Scalix-Mail-Server zugestellt werden. Die richtige (externe) Mail-Domain und die (internen) Mail-Domains des LAN trage ich deshalb im File /etc/mail/local-host-names ein:

localhost
scx
Zuhause.xx
scx.Zuhause.xx
Meine-Domain.de

Die beiden Domains (hier: Zuhause.xx und Meine-Domain.de) müssen in Scalix als Lokale Domain definiert werden (SAC: Einstellungen - Administration - Lokale Domains).

Der Smarthost für ausgehende Emails wird wie folgt definiert, entweder in sendmail.mc (oder z.B. unter /etc/mail/m4/provider.m4):

define(`SMART_HOST', `smtp.1und1.de')
MASQUERADE_AS(`Meine-Domain.de')dnl

Das Login / Passwort für den Smarthost definiert man unter /etc/mail/auth/client-info eingetragen:

AuthInfo:smtp.1und1.de "U:login" "I:login@mail.domain" "P:passwd"

Ein anschliessendes makemap im Verzeichnis /etc/mail/auth erzeugt die zugehörige Hash-Datei /etc/mail/auth/client-info.db.

cd /etc/mail/auth
makemap hash client-info <client-info

Zusätzlich trage ich einen Alias ein, damit die internen Mails (z.B. für root) an meinen normalen Account auf dem Scalix Server gesendet werden:

# cd /etc/mail
# vi aliases
root:     neobiker
neobiker: ich@Zuhause.xx

Sendmail starten

Für den zusätzlichen MTA-RX Prozess muss eine Queue-Verzeichnis angelegt werden:

cp -rp /var/spool/mqueue /var/spool/mqueue-rx

Anschliessend kann Sendmail gestartet werden, vorher zur Sicherheit die Konfigdateien aktualisieren:

cd /etc/mail
make
m4 /etc/mail/sendmail-rx.mc > /etc/mail/sendmail-rx.cf
m4 /etc/mail/sendmail.mc    > /etc/mail/sendmail.cf

/usr/sbin/sendmail -C /etc/mail/sendmail-rx.cf -L sm-mta-rx -bd -qp
/usr/sbin/sendmail                             -L sm-mta-tx -bd -q15m
/usr/sbin/sendmail -Ac                         -L sm-msp-queue -q10m

Sendmail-Dual Initscript

Ich habe das normale Sendmail-Initscript angepasst, damit der 2.te Sendmail-Prozess (MTA-RX zus. zu MTA-TX) berücksichtigt wird. Die Anpassungen sind im wesentlichen aus den normalen Prozeduren kopiert und angepasst. Im Original werden die Variablen MTAL_XXXX verwendet, ich habe für den zusätzlichen MTA-RX Prozess diese einfach als MTAR_XXXX wo nötig ergänzt und eingefügt.

Das Init-Script sendmail-dual steht hier zum Download. /etc/init.d/sendmail-dual -> Ich habe das normale /etc/init.d/sendmail File ersetzt.

Sendmail starten

Starten wie üblich, zum Debuggen den tail Befehl verwenden, monitoring mit ps:

# /etc/init.d/sendmail-dual start
# ps aux|grep -v grep|grep sendmail
root      5885  0.0  1.5   8344  2604 ?        Ss   19:11   0:00 sendmail: MTA: accepting connections
smmta     5886  0.0  1.0   8336  1764 ?        S    19:11   0:00 sendmail: MTA: running queue: /var/spool/mqueue-rx
root      5890  0.0  1.5   8332  2612 ?        Ss   19:11   0:00 sendmail: MTA: accepting connections
#
# tail -f /var/log/mail.info &

Weiter mit Scalix Installation