diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2003-10-10 10:55:46 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2003-10-10 10:55:46 +0000 |
commit | 30884a491e4fca0ade13b594565beef2136bb1e8 (patch) | |
tree | aa5f0af47e0570af98e321798e96d6b7745eae57 /sink.c | |
parent | 33bc965543517dedfbff9299f9e8af6ffa14c5db (diff) | |
download | fetchmail-30884a491e4fca0ade13b594565beef2136bb1e8.tar.gz fetchmail-30884a491e4fca0ade13b594565beef2136bb1e8.tar.bz2 fetchmail-30884a491e4fca0ade13b594565beef2136bb1e8.zip |
Close a Debian bug.
svn path=/trunk/; revision=3840
Diffstat (limited to 'sink.c')
-rw-r--r-- | sink.c | 34 |
1 files changed, 33 insertions, 1 deletions
@@ -211,7 +211,39 @@ int smtp_open(struct query *ctl) ctl->destaddr = (ctl->smtphost && ctl->smtphost[0] != '/') ? ctl->smtphost : "localhost"; } else - ctl->destaddr = ctl->smtpaddress ? ctl->smtpaddress : ( ctl->smtphost && ctl->smtphost[0] != '/' ? ctl->smtphost : "localhost"); + { + /* + * Here we try to find a correct domain name part for the RCPT + * TO address. If smtpaddress is set, no need to guestimate + * it. Otherwise, using ctl->smtphost as a base is a good + * base, although we may have to strip any port appended to + * communicate with SMTP servers that do not listen on the + * SMTP port. (benj) */ + if (ctl->smtpaddress) + ctl->destaddr = ctl->smtpaddress; + else if (ctl->smtphost && ctl->smtphost[0] != '/') + { + char * cp; + if (cp = strchr (ctl->smtphost, '/')) + { + /* As an alternate port for smtphost is specified, we + need to strip it from domain name. */ + char *smtpname; + xalloca(smtpname, char *, cp - ctl->smtphost + 1); + strncpy(smtpname, ctl->smtphost, cp - ctl->smtphost +1); + cp = strchr(smtpname, '/'); + *cp = 0; + ctl->destaddr = smtpname; + } + else + /* No need to strip port, domain name is smtphost. */ + ctl->destaddr = ctl->smtphost; + } + /* No smtphost is specified or it is a UNIX socket, then use + localhost as a domain part. */ + else + ctl->destaddr = "localhost"; + } if (outlevel >= O_DEBUG && ctl->smtp_socket != -1) report(stdout, GT_("forwarding to %s\n"), ctl->smtphost); |