Dovecot Proxy LTMP client connect to TCP port 0
Wido den Hollander
wido at widodh.nl
Sat Apr 9 09:25:42 UTC 2016
Hi,
I am trying to set up a Dovecot proxy which proxies through POP3, IMAP and LTMP
towards a different Dovecot machine.
On the proxy machine I use a MySQL database as a userdb and passwdb backend and
it returns the proper information as described here:
http://wiki2.dovecot.org/PasswordDatabase/ExtraFields/Proxy
IMAP and POP3 works just fine, but with LMTP I run into a problem.
On the 'proxy' machine Postfix is also running and it deliver locally to LTMP
via Socket:
virtual_transport = lmtp:unix:private/dovecot-lmtp
Dovecot there is also configured to proxy LTMP:
lmtp_proxy = yes
service lmtp {
unix_listener /var/spool/postfix/private/dovecot-lmtp {
group = postfix
mode = 0600
user = postfix
}
}
So far so good. A telnet to localhost 110 or 143 allows me to log in to the
POP3/IMAP.
When Postfix delivers the message locally to Dovecot through LTMP it tries to
proxy it though.
When doing so it tries to connect to TCP port 0 (zero).
dovecot: lmtp(22580): Error: lmtp client: connect(mbox01.XXXX.nl, 0) failed:
Connection refused
I know I can return the 'port' field in the userdb query, but the same query is
used for POP3, IMAP and LMTP. So that can't be hardcoded.
I fixed it for now with a CASE statement in SQL:
password_query = SELECT b.hostname AS host, NULL AS password, \
'Y' AS nopassword, u.email AS destuser, 'Y' AS proxy, \
CASE '%s' WHEN 'lmtp' THEN 2525 WHEN 'pop3' THEN 110 WHEN 'imap' THEN 143
END AS port \
FROM User u, Backend b, Domain d \
WHERE u.domainID = d.domainID \
AND b.backendID = d.backendID \
AND u.email = '%u'
%s is a variable containing the service Dovecot is trying to look up.
This is however rather hacky.
On my destination machine LMTP is listening on port 2525. Is there any way to
tell the Dovecot LTMP client to connect to port 2525 by default?
Thanks,
Wido
More information about the dovecot
mailing list