Mijn vraag
Ik wil graag Postfix en Dovecot (in Docker containers) koppelen. De opzet is om Dovecot te koppelen aan de gebruikerslijkst die via LDAP beschikbaar is. Dovecot zal verder IMAP en LMTP doen. Postfix zal SMTP en mail submission doen, en bij Dovecot nagaan of het een geldige gebruiker of ontvangst-emailadres is.
Ik wil graag dat gebruikers met hun UID of mail-adres kunnen inloggen. Dat zal dan verder door dovecot worden genormaliseerd naar het mail adres. Bij het testen van Dovecot (via de betreffende services en met doveadm) werkt dat ook naar behoren.
Maar op de een of andere manier gaat er iets mis in de communicatie met Postfix, Postfix accepteert mail voor gebruikersnaam@domein.tld, terwijl alleen daadwerkelijke emailadressen moeten worden geaccepteerd, bijvoorbeeld voornaam.achternaam@domein.tld.
Volgens dovecot zelf is gebruikersnaam@domein.tld geen geldige gebruikernaam, alleen voor gebruikersnaam of voornaam.achternaam@domein.tld slaagt een user lookup of een authenticatie (zoals zou moeten dus ook).
Ik snap niet waarom Postfix wel mail voor gebruikersnaam@domein.tld accepteert. De Dovecots LMTP weigert vervolgens natuurlijk het bericht dat postfix wil aanbieden (bounce). Het lijkt erop dat postfix alleen "gebruikersnaam" laat valideren, en daar zelf @domein.tld achter hangt.
Relevante software en hardware die ik gebruik
Postfix 3.7.4, Dovecot 2.3.20
Ik heb het vermoeden dat het probleem in de Postfix-configuratie zit...
Voor de volledigheid even de configuraties:
dovecot.conf:
dovecot-ldap.conf
postfix main.cf:
postfix master.cf:
(het is verder niet zo dat "username@domain.tld" terugkomt in de alsiases oid)
Ik wil graag Postfix en Dovecot (in Docker containers) koppelen. De opzet is om Dovecot te koppelen aan de gebruikerslijkst die via LDAP beschikbaar is. Dovecot zal verder IMAP en LMTP doen. Postfix zal SMTP en mail submission doen, en bij Dovecot nagaan of het een geldige gebruiker of ontvangst-emailadres is.
Ik wil graag dat gebruikers met hun UID of mail-adres kunnen inloggen. Dat zal dan verder door dovecot worden genormaliseerd naar het mail adres. Bij het testen van Dovecot (via de betreffende services en met doveadm) werkt dat ook naar behoren.
Maar op de een of andere manier gaat er iets mis in de communicatie met Postfix, Postfix accepteert mail voor gebruikersnaam@domein.tld, terwijl alleen daadwerkelijke emailadressen moeten worden geaccepteerd, bijvoorbeeld voornaam.achternaam@domein.tld.
Volgens dovecot zelf is gebruikersnaam@domein.tld geen geldige gebruikernaam, alleen voor gebruikersnaam of voornaam.achternaam@domein.tld slaagt een user lookup of een authenticatie (zoals zou moeten dus ook).
Ik snap niet waarom Postfix wel mail voor gebruikersnaam@domein.tld accepteert. De Dovecots LMTP weigert vervolgens natuurlijk het bericht dat postfix wil aanbieden (bounce). Het lijkt erop dat postfix alleen "gebruikersnaam" laat valideren, en daar zelf @domein.tld achter hangt.
Relevante software en hardware die ik gebruik
Postfix 3.7.4, Dovecot 2.3.20
Ik heb het vermoeden dat het probleem in de Postfix-configuratie zit...
Voor de volledigheid even de configuraties:
dovecot.conf:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
| # 2.3.20 (80a5ac675d): /etc/dovecot/dovecot.conf
# Pigeonhole version 0.5.19 (4eae2f79)
# OS: Linux 4.4.180+ x86_64
# Hostname: aaaa
auth_debug = yes
auth_mechanisms = plain login
auth_verbose = yes
debug_log_path = /dev/stdout
first_valid_uid = 90
info_log_path = /dev/stdout
last_valid_uid = 90
listen = *
log_path = /dev/stdout
mail_debug = yes
mail_gid = dovecot
mail_home = /srv/mail/%Ld/%Ln
mail_location = sdbox:~/Mail
mail_plugins = " acl quota zlib"
mail_uid = dovecot
managesieve_notify_capability = mailto
managesieve_sieve_capability = fileinto reject envelope encoded-character vacation subaddress comparator-i;ascii-numeric relational regex imap4flags copy include variables body enotify environment mailbox date index ihave duplicate mime foreverypart extracttext
namespace inbox {
inbox = yes
location =
mailbox Archive {
auto = subscribe
special_use = \Archive
}
mailbox Drafts {
auto = subscribe
special_use = \Drafts
}
mailbox Junk {
auto = subscribe
special_use = \Junk
}
mailbox Sent {
auto = subscribe
special_use = \Sent
}
mailbox "Sent Messages" {
special_use = \Sent
}
mailbox Trash {
auto = subscribe
special_use = \Trash
}
prefix =
separator = /
}
passdb {
args = /etc/dovecot/dovecot-ldap.conf
driver = ldap
}
plugin {
acl = vfile
acl_shared_dict = file:/srv/mail/shared-mailboxes-dict
}
postmaster_address = postmaster@domain.tld
protocols = lmtp imap sieve
service auth {
inet_listener {
port = 10010
}
}
service lmtp {
inet_listener {
port = 24
}
user = dovecot
}
ssl = required
ssl_cert = </etc/ssl/dovecot/domain.tld.crt
ssl_dh = # hidden, use -P to show it
ssl_key = # hidden, use -P to show it
ssl_prefer_server_ciphers = yes
userdb {
args = /etc/dovecot/dovecot-ldap.conf
driver = ldap
override_fields = uid=dovecot gid=dovecot home=/srv/mail/%Ln-%N{userdb:mail:default} mail=sdbox:/srv/mail/%Ln-%N{userdb:mail:default}/Mail
}
verbose_ssl = yes
protocol imap {
mail_plugins = " acl quota zlib imap_acl imap_quota"
} |
dovecot-ldap.conf
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
| # Connect dovecot to LDAP
uris = ldaps://ldap.domain.tld
ldap_version = 3
blocking = yes
dn = uid=ldapclient,cn=users,dc=domain,dc=tld
dnpass = xxx
# The node with users
base = cn=users,dc=domain,dc=tld
scope = subtree
auth_bind = yes
#auth_bind_userdn = uid=%n,cn=users,dc=domain,dc=tld
# Filter to find users based on the username or email-adress
pass_filter = (&(&(|(objectclass=inetOrgPerson))(|(memberof=cn=domain users,cn=groups,dc=domain,dc=tld)))(|(uid=%u)(|(mail=%u))))
pass_attrs = =user=%{ldap:uid}, userPassword=password
# Filter to find users based on the username or email-adress
user_filter = (&(&(|(objectclass=inetOrgPerson))(|(memberof=cn=domain users,cn=groups,dc=domain,dc=tld)))(|(uid=%u)(|(mail=%u))))
user_attrs = =user=%{ldap:uid}, mail
# Attributes and filter to get a list of all users
iterate_attrs = uid=user
iterate_filter = (&(|(objectclass=inetOrgPerson))(|(memberof=cn=domain users,cn=groups,dc=domain,dc=tld)))
default_pass_scheme = PLAIN |
postfix main.cf:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
| mydomain = domain.tld
myhostname = mail.$mydomain
mynetworks = 127.0.0.0/8, localhost
# 172.200.0.0/16 is anything from our docker bridge
mydestination = 172.20.0.0/16, localhost.$mydomain, 172.200.0.0/16, localhost
relay_domains =
myorigin = $mydomain
smtpd_banner = $myhostname ESMTP
virtual_mailbox_domains = $mydomain
virtual_transport = lmtp:dovecot:24
virtual_alias_maps = lmdb:/etc/postfix/virtual
smtpd_sasl_type = dovecot
# That's the port we configure in the dovecot service auth section
smtpd_sasl_path = inet:dovecot:10010
smtpd_sasl_auth_enable = yes
smtpd_sasl_tls_security_options = noanonymous
smtpd_tls_auth_only = yes
smtpd_tls_ciphers = high
smtpd_tls_cert_file = /etc/postfix/domain.tld.crt
smtpd_tls_key_file = /etc/postfix/domain.tld.key
smtpd_tls_security_level = may
smtp_tls_security_level = may
### logging and debugging: docker friendly logging and minimal error output
notify_classes = resource, software
maillog_file = /dev/stdout
### Other MTAs must use a proper HELO as specified in RFC5321
smtpd_helo_required = yes
# Disables harvesting mail addresses
disable_vrfy_command = yes
# Reject mail only after RCPT TO, improves compatibility
smtpd_delay_reject = yes
smtpd_recipient_restrictions =
# allow clients from our local network
permit_mynetworks
# allow authenticated users
permit_sasl_authenticated
# reject hosts without fqdn hostname
reject_non_fqdn_helo_hostname
# reject mails without fqdn sender
reject_non_fqdn_sender
# reject mails without fqdn recipient
reject_non_fqdn_recipient
# reject mails when we are not the final sender domain
reject_unknown_sender_domain
# reject mails to domains we don't host
reject_unknown_recipient_domain
reject_unauth_destination
# reject mails with malformed HELO
check_helo_access regexp:/etc/postfix/helo_checks
# reject mails from IPs that are not plausible
check_sender_mx_access cidr:/etc/postfix/bogus_mx
# allow mails to special addresses
check_recipient_access lmdb:/etc/postfix/roleaccount_exceptions
# reject mails to users we don't host
reject_unverified_recipient
# finally, start reading the rest of the mail
permit
smtpd_data_restrictions =
# reject the mail when the client sends SMTP commands out of order
reject_unauth_pipelining
# reject null sender addresses
reject_multi_recipient_bounce
permit |
postfix master.cf:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
| smtp inet n - n - - smtpd
submission inet n - n - - smtpd
-o smtpd_tls_security_level=encrypt
-o milter_macro_daemon_name=ORIGINATING
pickup unix n - n 60 1 pickup
cleanup unix n - n - 0 cleanup
qmgr unix n - n 300 1 qmgr
#qmgr unix n - n 300 1 oqmgr
tlsmgr unix - - n 1000? 1 tlsmgr
rewrite unix - - n - - trivial-rewrite
bounce unix - - n - 0 bounce
defer unix - - n - 0 bounce
trace unix - - n - 0 bounce
verify unix - - n - 1 verify
flush unix n - n 1000? 0 flush
proxymap unix - - n - - proxymap
proxywrite unix - - n - 1 proxymap
smtp unix - - n - - smtp
relay unix - - n - - smtp
-o syslog_name=postfix/$service_name
showq unix n - n - - showq
error unix - - n - - error
retry unix - - n - - error
discard unix - - n - - discard
local unix - n n - - local
virtual unix - n n - - virtual
lmtp unix - - n - - lmtp
anvil unix - - n - 1 anvil
scache unix - - n - 1 scache
postlog unix-dgram n - n - 1 postlogd |
(het is verder niet zo dat "username@domain.tld" terugkomt in de alsiases oid)