From 679047bd6a8d9387e1dbb724a1e4763aa7d3bbfc Mon Sep 17 00:00:00 2001 From: Matthias Andree Date: Wed, 21 Feb 2007 21:29:57 +0000 Subject: Try --smtp list when bouncing. Reported by Christian Kurz, Debian Bug #150137. svn path=/branches/BRANCH_6-3/; revision=5041 --- sink.c | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) (limited to 'sink.c') diff --git a/sink.c b/sink.c index 92477ef9..afd1439e 100644 --- a/sink.c +++ b/sink.c @@ -258,6 +258,7 @@ static int send_bouncemail(struct query *ctl, struct msgblk *msg, char daemon_name[15 + HOSTLEN] = "MAILER-DAEMON@"; char boundary[BUFSIZ], *bounce_to; int sock; + struct idlist *ish; static char *fqdn_of_host = NULL; const char *md1 = "MAILER-DAEMON", *md2 = "MAILER-DAEMON@"; @@ -276,10 +277,37 @@ static int send_bouncemail(struct query *ctl, struct msgblk *msg, lose the NDN here */ strlcat(daemon_name, fqdn_of_host, sizeof(daemon_name)); + /* XXX FIXME: we blindly assume that any host on our smtphunt list + * and offers SMTP will accept our bounce; however, in global lmtp + * mode we'll just try localhost instead. */ /* we need only SMTP for this purpose */ - /* XXX FIXME: hardcoding localhost is nonsense if smtphost can be - * configured */ - if ((sock = SockOpen("localhost", SMTP_PORT, NULL, &ai1)) == -1) + sock = -1; + if (ctl->smtphunt && ctl->listener == SMTP_MODE) { + for (ish = ctl->smtphunt ; ish; ish = ish->next) { + char *x = xstrdup(ish->id), *y, *port; + + /* skip over LMTP entries */ + if (x[0] == '/') { + free(x); + continue; + } + + if ((y = strrchr(x, '/'))) { + *y = '\0'; + port = y + 1; + } else { + port = SMTP_PORT; + } + sock = SockOpen(x, port, NULL, &ai1); + free(x); + if (sock != -1) + break; + } + } else { + sock = SockOpen("localhost", SMTP_PORT, NULL, &ai1); + } + + if (sock == -1) return(FALSE); if (SMTP_ok(sock, SMTP_MODE) != SM_OK) -- cgit v1.2.3