• Willkommen im Linux Club - dem deutschsprachigen Supportforum für GNU/Linux. Registriere dich kostenlos, um alle Inhalte zu sehen und Fragen zu stellen.

[gelöst] Per Fetchmail in virt. Mailboxen liefern (Dovecot)

hachr6

Newbie
Hallo. Meine nächtelange Suche nach Lösung des Problems brachte mich leider nicht weiter, deswegen frage ich nun mal hier. Alles was ich probiert habe funktionierte nicht :-(

Ich habe einen Mailserver nach dieser Anleitung aufgesetzt http://www.foteviken.de/?p=1925 und es funktioniert auch alles soweit. Als System benutze ich ein Debian 7.
Damit man sich nicht den ganzen Artikel durchlesen muss...ich habe folgendes aufgesetzt:

Code:
Samba4 mit Active Directory
Postfix und Dovecot als IMAP Server (mit Anbindung ans AD und virtuellen Mailboxen)

Nun möchte ich noch Mails von extern holen lassen mit fetchmail und genau da liegt das Problem.
Intern und nach extern Mails verschicken geht schon...

Fetchmail soll nun die Mails einsammeln und in die virtuellen Mailboxen (Inbox) einliefern. Doch wie bekomme ich das hin, das fetchmail gleich in die virtuellen Mailboxen einliefert?
Mit lokalen Benutzern (so, wie ich es auf einem anderen System schon am laufen habe) wäre es ja einfach...

Hier meine aktuellen config-Dateien:

main.cf
Code:
# See /usr/share/postfix/main.cf.dist for a commented, more complete version


# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h
bounce_queue_lifetime = 3d
delay_warning_time = 1h
readme_directory = no
readme_directory = no

# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls = yes
# smtp_use_tls = yes
#smtpd_enforce_tls = yes
smtp_tls_security_level = may
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtp_tls_policy_maps = hash:/etc/postfix/tls_policy

# Enable smtp authentication
smtpd_sasl_auth_enable = yes
smtp_sasl_auth_enable = yes
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain = <mydomain.tld>
smtp_sasl_password_maps = hash:/etc/postfix/passes
smtp_sasl_security_options = noanonymous

# Virtual mailbox configuration
# Domains seperated by ,
virtual_mailbox_domains = <mydomain.tld>
virtual_mailbox_base = /var/mail
virtual_uid_maps = 5000
virtual_gid_maps = 5000
virtual_transport = lmtp:unix:private/dovecot-lmtp
# virtual_transport = dovecot

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = <hostname.mydomain.tld>
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
sender_dependent_relayhost_maps = hash:/etc/postfix/relaymap
smtp_sender_dependent_authentication = yes
myorigin = /etc/mailname
#myorigin = $myhostname
mydestination = <hostname.mydomain.tld>, localhost.<mydomain.tld>, localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 192.168.xxx.0/24
inet_interfaces = 127.0.0.1, 192.168.xxx.yyy
#mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
recipient_delimiter = +
#inet_interfaces = all
disable_dns_lookups = no

address_verify_negative_cache = no

#Policies
#strict_rfc831_envelopes = yes
#disable_vrfy_command = yes
smtpd_delay_reject = yes
smtpd_helo_required = yes

#Custom responses
#unverified_recipient_reject_reason = 550 5.1.1 User doesn't exist.

smtpd_helo_restrictions = 
#permit_sasl_authenticated,
       #reject_invalid_helo_hostname,
       #reject_non_fqdn_helo_hostname,
       #reject_unknown_helo_hostname

smtpd_client_restrictions = 
#permit_sasl_authenticated,
       #reject_unknown_client_hostname,
       #reject_unknown_client,
       #reject_unknown_sender_domain

smtpd_recipient_restrictions = permit_mynetworks,
        permit_sasl_authenticated,
        reject_unverified_recipient,
        reject_unauth_destination
        #check_helo_access hash:/etc/postfix/helo_checks
        #check_sender_access hash:/etc/postfix/sender_checks,
        #check_client_access hash:/etc/postfix/client_checks,
        #reject_unknown_sender_domain,
        #reject_non_fqdn_recipient,
        #reject_unauth_destination,
        #reject_unknown_recipient_domain,
        #reject_unverified_recipient

smtpd_data_restrictions =

smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
smtp_tls_loglevel = 1

master.cf
Code:
#
# Postfix master process configuration file.  For details on the format
# of the file, see the master(5) manual page (command: "man 5 master").
#
# Do not forget to execute "postfix reload" after editing this file.
#
# ==========================================================================
# service type  private unpriv  chroot  wakeup  maxproc command + args
#               (yes)   (yes)   (yes)   (never) (100)
# ==========================================================================
smtp      inet  n       -       -       -       -       smtpd
#submission inet n       -       -       -       -       smtpd
#  -o smtpd_tls_security_level=encrypt
#  -o smtpd_sasl_auth_enable=yes
#  -o smtpd_sasl_type=dovecot
#  -o smtpd_sasl_path=/var/spool/postfix/private/auth
#  -o smtpd_sasl_recipient_restrictions=reject_unknown_recipient_domain,reject_non_fqdn_recipient, permit_sasl_authenticated,reject
#  -o smtpd_client_restrictions=permit_sasl_authenticated,reject
#  -o milter_macro_daemon_name=ORIGINATING
#smtps     inet  n       -       -       -       -       smtpd
#  -o smtpd_tls_wrappermode=yes
#  -o smtpd_sasl_auth_enable=yes
#  -o smtpd_client_restrictions=permit_sasl_authenticated,reject
#  -o milter_macro_daemon_name=ORIGINATING
#628       inet  n       -       -       -       -       qmqpd
pickup    fifo  n       -       -       60      1       pickup
cleanup   unix  n       -       -       -       0       cleanup
qmgr      fifo  n       -       n       300     1       qmgr
#qmgr     fifo  n       -       -       300     1       oqmgr
tlsmgr    unix  -       -       -       1000?   1       tlsmgr
rewrite   unix  -       -       -       -       -       trivial-rewrite
bounce    unix  -       -       -       -       0       bounce
defer     unix  -       -       -       -       0       bounce
trace     unix  -       -       -       -       0       bounce
verify    unix  -       -       -       -       1       verify
flush     unix  n       -       -       1000?   0       flush
proxymap  unix  -       -       n       -       -       proxymap
proxywrite unix -       -       n       -       1       proxymap
smtp      unix  -       -       -       -       -       smtp
# When relaying mail as backup MX, disable fallback_relay to avoid MX loops
relay     unix  -       -       -       -       -       smtp
        -o smtp_fallback_relay=
#       -o smtp_helo_timeout=5 -o smtp_connect_timeout=5
showq     unix  n       -       -       -       -       showq
error     unix  -       -       -       -       -       error
retry     unix  -       -       -       -       -       error
discard   unix  -       -       -       -       -       discard
local     unix  -       n       n       -       -       local
virtual   unix  -       n       n       -       -       virtual
lmtp      unix  -       -       -       -       -       lmtp
anvil     unix  -       -       -       -       1       anvil
scache    unix  -       -       -       -       1       scache
#
# ====================================================================
# Interfaces to non-Postfix software. Be sure to examine the manual
# pages of the non-Postfix software to find out what options it wants.
#
# Many of the following services use the Postfix pipe(8) delivery
# agent.  See the pipe(8) man page for information about ${recipient}
# and other message envelope options.
# ====================================================================
#
# maildrop. See the Postfix MAILDROP_README file for details.
# Also specify in main.cf: maildrop_destination_recipient_limit=1
#
maildrop  unix  -       n       n       -       -       pipe
  flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}
#
# ====================================================================
#
# Recent Cyrus versions can use the existing "lmtp" master.cf entry.
#
# Specify in cyrus.conf:
#   lmtp    cmd="lmtpd -a" listen="localhost:lmtp" proto=tcp4
#
# Specify in main.cf one or more of the following:
#  mailbox_transport = lmtp:inet:localhost
#  virtual_transport = lmtp:inet:localhost
#
# ====================================================================
#
# Cyrus 2.1.5 (Amos Gouaux)
# Also specify in main.cf: cyrus_destination_recipient_limit=1
#
#cyrus     unix  -       n       n       -       -       pipe
#  user=cyrus argv=/cyrus/bin/deliver -e -r ${sender} -m ${extension} ${user}
#
# ====================================================================
# Old example of delivery via Cyrus.
#
#old-cyrus unix  -       n       n       -       -       pipe
#  flags=R user=cyrus argv=/cyrus/bin/deliver -e -m ${extension} ${user}
#
# ====================================================================
#
# See the Postfix UUCP_README file for configuration details.
#
uucp      unix  -       n       n       -       -       pipe
  flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
#
# Other external delivery methods.
#
ifmail    unix  -       n       n       -       -       pipe
  flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
bsmtp     unix  -       n       n       -       -       pipe
  flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient
scalemail-backend unix  -       n       n       -       2       pipe
  flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension}
mailman   unix  -       n       n       -       -       pipe
  flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py
  ${nexthop} ${user}
#dovecot   unix  -       n       n       -       -       pipe
#  flags=DRhu user=vmail argv=/usr/lib/dovecot/deliver -d ${user}
#dovecot   unix  -       n       n       -       -       pipe
#  flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -f ${sender} -a ${recipient}

fetchmailrc
Code:
set daemon 120
set logfile /var/log/fetchmail/fetchmail.log
set no bouncemail
set postmaster vmail
poll pop.gmx.net protocol pop3 interval 3 user xyz@gmx.de password pwd keep ssl sslfingerprint "1234" sslcertck sslcertpath /etc/ssl/certs 
poll pop.gmx.net protocol pop3 interval 3 user zxy@gmx.net password pwd keep ssl sslfingerprint "1234" sslcertck sslcertpath /etc/ssl/certs
poll pop.gmx.net protocol pop3 interval 3 user abc@gmx.de password pwd keep ssl sslfingerprint "1234" sslcertck sslcertpath /etc/ssl/certs
poll abc.webpack.hosteurope.de protocol pop3 interval 2 user nutzer password pwd keep ssl sslfingerprint "4321" sslcertck sslcertpath /etc/ssl/certs 
preconnect "date >> /var/log/fetchmail/fetchmail.log"

Ich habe gelesen, in der fetchmailrc kann man ein MDA angeben... aber wie mache ich das korrekt? Wie gesagt, meine Versuche waren nutzlos.
Habe schon Versuche mit dovecot-lda gemacht...im Tutorial steht was von maildrop... Wer wie was und wo muss ich machen/eintragen?

Danke.
 

drcux

Hacker
Fetchmail einfach sagen, für welchen User welches Postfach abgerufen wird, ob es virtuelle oder echte Nuter sind, spielt für fetchmail keine Rolle:

.. user xyz@gmx.de password pwd is "deinnutzer" here keep ...
 
OP
H

hachr6

Newbie
Habe nun ein bisschen rumgespielt, dabei ist aber ein neues Problem aufgetaucht.

Ich hatte vorher die Mail Adressen im AD so angelegt, wie sie in echt lauten, also z.B. ich@gmx.de. Habe ich diese Adresse in fetchmail angegeben, wurde natürlich gleich wieder weiter an die externe geschickt und nichts landete intern. Nun habe ich die Mail Adressen auf ich@localdomain.tld im AD eingetragen und schwups landen auch endlich die Mails lokal :)
Aber zu früh gefreut !
Wenn ich nun von intern nach extern schicken will, bekomme ich ja als Absender in der Mail ich@localdomain.tld. Um dies zu ändern habe ich eine "canonical" map angelegt, um die internen Adressen wieder auf ich@gmx.de umzuschreiben. Das funktioniert auch soweit, ABER wenn jetzt fetchmail an die interne Adresse liefern will, schreibt natürlich postfix gleich auf die externe um und versucht direkt wieder zu verschicken, anstatt lokal abzuliefern.

Das kann ja so nicht richtig sein :eek:0:
Da muss es doch eine bessere Lösung geben.
Kann man nicht fetchmail anweisen, direkt irgendwie in die Dovecot Mailboxen zu liefern?
 

spoensche

Moderator
Teammitglied
Das versenden kannst du mittels smtp Client Authentifizierung in der Postfix Konfiguration festlegen.
Code:
smtp_sasl_auth_enable = yes
smtp_sasl_security_options = noplaintext noanonymous
smtp_sasl_password_maps = hash:/etc/postfix/sasl_password
 
OP
H

hachr6

Newbie
Ja, das ist mir klar und das funktioniert ja auch. Ich kann von intern von z.b. user@localdomain.tld nach extern schicken und bekomme dann automatisch über die canonical map ich@gmx.de.
Das Problem ist, dass fetchmail die eingehenden Mails gleich wieder weg schicken will nach extern, da postfix scheinbar gleich auf die canonical map zurückgreift, die lokale auf die externe Adresse umschreibt und dann gleich wieder weg schickt.
Deaktiviere ich die canonical map, landen die Mails im Posteingang... aber dann kann ich natürlich nicht von intern nach extern schicken, da ich dann als Absender die interne Adresse hätte :roll:
 

spoensche

Moderator
Teammitglied
Code:
poll pop.gmx.net protocol pop3 interval 3 user "xyz@gmx.de" with pass "password" is "abc@localdomain.tld§ here

müsste funktionieren.
 
OP
H

hachr6

Newbie
Nein, leider nicht.
Postfix versucht immer noch die eingegangenen Nachrichten gleich wieder weg zu schicken nach extern, anstatt sie lokal zu behalten.
Wie gesagt, es wird wohl so ablaufen, dass die interne Adresse gleich umgeschrieben wird über die canonical map und postfix denkt dann, es müsse die Nachricht wieder raus schicken (weil es ja dann eine externe Adresse ist).
 
OP
H

hachr6

Newbie
Ha ! Ich glaube, ich habe es hinbekommen :thumbs:

"canonical_maps" aus der postfix main.cf rausgeschmissen, stattdessen eine "sender_canonical_maps" angelegt mit dem Inhalt
Code:
ich-intern@internedomain.tld     ich-extern@gmx.de

Nur mit der sender_canonical_maps alleine wurde allerdings noch der interne Name mit übertragen, so dass der Empfänger dann nur auf die interne Mail Adresse hätte antworten können.
Also habe ich noch eine "smtp_generic_maps" angelegt mit
Code:
ich-intern@internedomain.tld     ich-extern@gmx.de
. Nun wird als Absenderadresse auch die ich-extern@gmx.de übertragen.

In fetchmailrc habe ich jetzt folgendes eingetragen:
Code:
poll pop.gmx.net protocol pop3 interval 3 user "abc@gmx.de" with password "pwd" is "ich-intern@internedomain.tld" here keep ssl sslfingerprint "1234" sslcertck sslcertpath /etc/ssl/certs


Ich hoffe das war die Lösung des Problems.
Gönne mir jetzt erst mal eine Pause und wenn die Tage alles laufen sollte, wird der erste Post mit [gelöst] markiert.
 
Oben