diff options
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | driver.c | 25 | ||||
-rw-r--r-- | fetchmail.man | 4 |
3 files changed, 26 insertions, 4 deletions
@@ -24,6 +24,7 @@ fetchmail-4.4.0 (): * net-security option is now per-server, with a `netsec' keyword. * Handle "account" token in .netrc. * Fix IMAP4rev1 detection. +* Added /-suffix capability to specify a port or service on smtphost args. There are 272 people on fetchmail-friends and 136 on fetchmail-announce. @@ -466,11 +466,30 @@ static int smtp_open(struct query *ctl) */ for (idp = ctl->smtphunt; idp; idp = idp->next) { + char *cp, *parsed_host = alloca(strlen(idp->id) + 1); +#ifdef INET6 + char *portnum = SMTP_PORT; +#else + int portnum = SMTP_PORT; +#endif /* INET6 */ + ctl->smtphost = idp->id; /* remember last host tried. */ - if ((ctl->smtp_socket = SockOpen(idp->id,SMTP_PORT)) == -1) + strcpy(parsed_host, idp->id); + if ((cp = strrchr(parsed_host, '/'))) + { + *cp++ = 0; +#ifdef INET6 + portnum = cp; +#else + portnum = atoi(cp); +#endif /* INET6 */ + } + + if ((ctl->smtp_socket = SockOpen(parsed_host,portnum)) == -1) continue; + /* first, probe for ESMTP */ if (SMTP_ok(ctl->smtp_socket) == SM_OK && SMTP_ehlo(ctl->smtp_socket, id_me, &ctl->server.esmtp_options) == SM_OK) @@ -484,7 +503,7 @@ static int smtp_open(struct query *ctl) ctl->smtp_socket = -1; /* if opening for ESMTP failed, try SMTP */ - if ((ctl->smtp_socket = SockOpen(idp->id,SMTP_PORT)) == -1) + if ((ctl->smtp_socket = SockOpen(parsed_host,portnum)) == -1) continue; if (SMTP_ok(ctl->smtp_socket) == SM_OK && @@ -497,7 +516,7 @@ static int smtp_open(struct query *ctl) } if (outlevel >= O_VERBOSE && ctl->smtp_socket != -1) - error(0, 0, "forwarding to SMTP port on %s", ctl->smtphost); + error(0, 0, "forwarding to %s", ctl->smtphost); return(ctl->smtp_socket); } diff --git a/fetchmail.man b/fetchmail.man index 00580479..a339dea7 100644 --- a/fetchmail.man +++ b/fetchmail.man @@ -207,7 +207,9 @@ Specify a hunt list of hosts to forward mail to (one or more hostnames, comma-separated). In ETRN mode, set the host that the mailserver is asked to ship mail to. Hosts are tried in list order; the first one that is up becomes the forwarding or ETRN target for the -current run. +current run. Each hostname may have a '/'-delimited suffix specifying +a port or service to forward to; the default is 25 (or "smtp" under +IPv6). .TP .B \-D domain, --smtpaddress domain (Keyword: smtpaddress) |