aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>1998-02-20 03:48:19 +0000
committerEric S. Raymond <esr@thyrsus.com>1998-02-20 03:48:19 +0000
commitcb8de067edef1f659ec465cdb08b518ab8c37a59 (patch)
tree3e6f93f1a5e979b5fb13d9a5f22d9c8f6551571e
parentfb1b1a429b783665c2697b5fb00c78013a138ed7 (diff)
downloadfetchmail-cb8de067edef1f659ec465cdb08b518ab8c37a59.tar.gz
fetchmail-cb8de067edef1f659ec465cdb08b518ab8c37a59.tar.bz2
fetchmail-cb8de067edef1f659ec465cdb08b518ab8c37a59.zip
We can specify target ports now.
svn path=/trunk/; revision=1657
-rw-r--r--NEWS1
-rw-r--r--driver.c25
-rw-r--r--fetchmail.man4
3 files changed, 26 insertions, 4 deletions
diff --git a/NEWS b/NEWS
index 550c5f45..bff8ca4d 100644
--- a/NEWS
+++ b/NEWS
@@ -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.
diff --git a/driver.c b/driver.c
index 1be1dc0e..a1bb1dd3 100644
--- a/driver.c
+++ b/driver.c
@@ -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)