ok I think I found the answer how:
qmail-remote-auth
by Jay Soffian, modified by tom@tomclegg.net
Add SMTP authentication support (AUTH LOGIN) to qmail-remote. This is useful for relaying outgoing mail to a smarthost which requires authentication.
My modifications:
This version sends base64-encoded username/password (Jay's version sends plain username/password).
Jay's version expects the server to say "AUTH=LOGIN\n"; this version will also accept "AUTH=LOGIN ". This is necessary for servers which say (for example) "AUTH=LOGIN PLAIN".
This version recognizes "AUTH LOGIN" as well as "AUTH=LOGIN" (recommended by David DeHaven, using an SBC mail server).
This version recognizes "AUTH PLAIN LOGIN" (recommended by Fernando Lemes da Silva, using paramonga.terra.com.br and smtp.koho.com.br).
Obviously this part of the code should be rewritten to handle the general case instead of the three preceding exceptions, but I haven't done that yet.
You need to install qmail-smtpd-auth as well, just because this patch needs base64.c and base64.h (and the attendant patches to Makefile).
To install:
cd /src/qmail-1.03
fetch
patch < qmail-remote-auth.patch
make qmail-remote
install -m 711 qmail-remote /var/qmail/bin/qmail-remoteTo relay outgoing mail for "example.com" to an SMTP server at 10.9.8.7 port 2500 with username "foo" and password "bar":
echo example.com:10.9.8.7:2500 foo bar >>/var/qmail/control/smtproutesTo relay all outgoing mail to an SMTP server at 10.9.8.7 port 25 with username "foo" and password "bar":
echo :10.9.8.7 foo bar >>/var/qmail/control/smtproutes