diff options
-rw-r--r-- | NEWS | 4 | ||||
-rw-r--r-- | driver.c | 11 | ||||
-rw-r--r-- | fetchmail-FAQ.html | 8 | ||||
-rw-r--r-- | fetchmail-features.html | 14 | ||||
-rw-r--r-- | fetchmail.c | 37 | ||||
-rw-r--r-- | fetchmail.h | 2 | ||||
-rw-r--r-- | fetchmail.man | 8 | ||||
-rw-r--r-- | options.c | 12 | ||||
-rw-r--r-- | sink.c | 25 |
9 files changed, 101 insertions, 20 deletions
@@ -2,6 +2,10 @@ (The `lines' figures total .c, .h, .l, and .y files under version control.) +* Julian Haight added support for arbitrary SMTP RCPT TO: control using: + --smtpname user@host. Should be useful for sites running multiple virtual + domains without local users, such as a cyrus IMAP installation. +* Julian Haight added hostaddr reporting in the "Received: from" clause. * NT material added to FAQ item O9. * Commented out the socket-shutdown code that was causing mystery hangs under Red Hat 6.2. We can live with a socket leak (assuming it comes back) nmore @@ -987,7 +987,16 @@ static int readheaders(int sock, if (!run.invisible && n != -1) { /* utter any per-message Received information we need here */ - sprintf(buf, "Received: from %s\r\n", ctl->server.truename); + if (ctl->server.trueaddr) { + sprintf(buf, "Received: from %s [%u.%u.%u.%u]\r\n", + ctl->server.truename, + (unsigned char)ctl->server.trueaddr[0], + (unsigned char)ctl->server.trueaddr[1], + (unsigned char)ctl->server.trueaddr[2], + (unsigned char)ctl->server.trueaddr[3]); + } else { + sprintf(buf, "Received: from %s\r\n", ctl->server.truename); + } n = stuffline(ctl, buf); if (n != -1) { diff --git a/fetchmail-FAQ.html b/fetchmail-FAQ.html index 12a81729..28e2f0ab 100644 --- a/fetchmail-FAQ.html +++ b/fetchmail-FAQ.html @@ -10,7 +10,7 @@ <table width="100%" cellpadding=0><tr> <td width="30%">Back to <a href="index.html">Fetchmail Home Page</a> <td width="30%" align=center>To <a href="/~esr/sitemap.html">Site Map</a> -<td width="30%" align=right>$Date: 2000/06/07 00:22:00 $ +<td width="30%" align=right>$Date: 2000/06/07 02:21:34 $ </table> <HR> <H1>Frequently Asked Questions About Fetchmail</H1> @@ -1002,8 +1002,8 @@ option to point fetchmail at it. That should solve the problem.<p> <h2><a name="C7">C7. How can I forward mail to another host?</a></h2> To forward mail to a host other than the one you are running fetchmail -on, use the <code>smtphost</code> option. See the manual page for -details.<p> +on, use the <code>smtphost</code> or <code>smtpname</code> option. +See the manual page for details.<p> <hr> <h2><a name="T1">T1. How can I use fetchmail with sendmail?</a></h2> @@ -2856,7 +2856,7 @@ install Linux on your server...<p> <table width="100%" cellpadding=0><tr> <td width="30%">Back to <a href="index.html">Fetchmail Home Page</a> <td width="30%" align=center>To <a href="/~esr/sitemap.html">Site Map</a> -<td width="30%" align=right>$Date: 2000/06/07 00:22:00 $ +<td width="30%" align=right>$Date: 2000/06/07 02:21:34 $ </table> <P><ADDRESS>Eric S. Raymond <A HREF="mailto:esr@thyrsus.com"><esr@snark.thyrsus.com></A></ADDRESS> diff --git a/fetchmail-features.html b/fetchmail-features.html index 5f24bfcd..983a55a0 100644 --- a/fetchmail-features.html +++ b/fetchmail-features.html @@ -10,7 +10,7 @@ <table width="100%" cellpadding=0><tr> <td width="30%">Back to <a href="index.html">Fetchmail Home Page</a> <td width="30%" align=center>To <a href="/~esr/sitemap.html">Site Map</a> -<td width="30%" align=right>$Date: 2000/06/07 00:22:01 $ +<td width="30%" align=right>$Date: 2000/06/07 02:21:34 $ </table> <HR> @@ -19,7 +19,15 @@ <H2>Since 5.0:</H2> <UL> <LI> -Fetchmail now runs on BeOS, thanks to David Reid" <david@jetnet.co.uk>. +Added --smtpname to set username and domain portion of SMTP "RCPT TO" +command. >fetchmail@mail.julianhaight.com>. + +<LI> +Added "from" server's IP address to inserted Received line +>fetchmail@mail.julianhaight.com<. + +<LI> +Fetchmail now runs on BeOS, thanks to David Reid <david@jetnet.co.uk>. <LI> In IMAP, unseen-message counting and indexing is now done by SEARCH @@ -213,7 +221,7 @@ get-mail, gwpop, pimp-1.0, pop-perl5-1.2, popc, popmail-1.6 and upop.<P> <table width="100%" cellpadding=0><tr> <td width="30%">Back to <a href="index.html">Fetchmail Home Page</a> <td width="30%" align=center>To <a href="/~esr/sitemap.html">Site Map</a> -<td width="30%" align=right>$Date: 2000/06/07 00:22:01 $ +<td width="30%" align=right>$Date: 2000/06/07 02:21:34 $ </table> <P><ADDRESS>Eric S. Raymond <A HREF="mailto:esr@thyrsus.com"><esr@snark.thyrsus.com></A></ADDRESS> diff --git a/fetchmail.c b/fetchmail.c index bce52ae5..dd83b671 100644 --- a/fetchmail.c +++ b/fetchmail.c @@ -831,6 +831,7 @@ static void optmerge(struct query *h2, struct query *h1, int force) FLAG_MERGE(bsmtp); FLAG_MERGE(listener); FLAG_MERGE(smtpaddress); + FLAG_MERGE(smtpname); FLAG_MERGE(preconnect); FLAG_MERGE(postconnect); @@ -1143,8 +1144,40 @@ static int load_params(int argc, char **argv, int optind) ctl->server.truename=xstrdup((char *)namerec->h_name); } #endif /* HAVE_GETHOSTBYNAME */ - else - ctl->server.truename = xstrdup(ctl->server.queryname); + else { +#ifdef HAVE_GETHOSTBYNAME + struct hostent *namerec; + + /* <fetchmail@mail.julianhaight.com> + Get the host's IP, so we can report it like this: + + Received: from hostname [10.0.0.1] + + do we actually need to gethostbyname to find the IP? + it seems like it would be faster to do this later, when + we are actually resolving the hostname for a connection, + but I ain't that smart, so I don't know where to make + the change later.. + */ + errno = 0; + namerec = gethostbyname(ctl->server.queryname); + if (namerec == (struct hostent *)NULL) + { + report(stderr, + _("couldn't find canonical DNS name of %s\n"), + ctl->server.pollname); + exit(PS_DNS); + } + else { + ctl->server.truename=xstrdup((char *)namerec->h_name); + ctl->server.trueaddr=xmalloc(namerec->h_length); + memcpy(ctl->server.trueaddr, + namerec->h_addr_list[0], + namerec->h_length); + } +#endif /* HAVE_GETHOSTBYNAME */ + ctl->server.truename = xstrdup(ctl->server.queryname); + } /* if no folders were specified, set up the null one as default */ if (!ctl->mailboxes) diff --git a/fetchmail.h b/fetchmail.h index c91f834d..fd5403ed 100644 --- a/fetchmail.h +++ b/fetchmail.h @@ -222,6 +222,7 @@ struct hostdata /* shared among all user connections to given server */ int poll_count; /* count of polls so far */ char *queryname; /* name to attempt DNS lookup on */ char *truename; /* "true name" of server host */ + char *trueaddr; /* IP address of truename, as char */ struct hostdata *lead_server; /* ptr to lead query for this server */ int esmtp_options; }; @@ -241,6 +242,7 @@ struct query /* per-forwarding-target data */ struct idlist *smtphunt; /* list of SMTP hosts to try forwarding to */ char *smtpaddress; /* address to force in RCPT TO */ + char *smtpname; /* full RCPT TO name, including domain */ struct idlist *antispam; /* list of listener's antispam response */ char *mda; /* local MDA to pass mail to */ char *bsmtp; /* BSMTP output file */ diff --git a/fetchmail.man b/fetchmail.man index 3da20fcb..1809acad 100644 --- a/fetchmail.man +++ b/fetchmail.man @@ -319,6 +319,11 @@ Specify the domain to be put in RCPT TO lines shipped to SMTP. The name of the SMTP server (as specified by --smtphost, or defaulted to "localhost") is used when this is not specified. .TP +.B --smtpname <user@domain> +(Keyword: smtpname) +Specify the domain and user to be put in RCPT TO lines shipped to SMTP. +The default user is the current local user. +.TP .B \-Z <nnn>, --antispam <nnn[, nnn]...> (Keyword: antispam) Specifies the list of numeric SMTP errors that are to be interpreted @@ -1209,6 +1214,9 @@ T} smtpaddress -D T{ Specify the domain to be put in RCPT TO lines T} +smtpname T{ +Specify the user and domain to be put in RCPT TO lines +T} antispam -Z T{ Specify what SMTP returns are interpreted as spam-policy blocks T} @@ -70,11 +70,12 @@ #define LA_MONITOR 46 #define LA_CONFIGDUMP 47 #define LA_YYDEBUG 48 +#define LA_SMTPNAME 49 #ifdef SSL_ENABLE -#define LA_SSL 49 -#define LA_SSLKEY 50 -#define LA_SSLCERT 51 +#define LA_SSL 50 +#define LA_SSLKEY 51 +#define LA_SSLCERT 52 #endif /* options still left: CDgGhHjJoORwWxXYz */ @@ -123,6 +124,7 @@ static const struct option longoptions[] = { {"folder", required_argument, (int *) 0, LA_FOLDER }, {"smtphost", required_argument, (int *) 0, LA_SMTPHOST }, {"smtpaddress", required_argument, (int *) 0, LA_SMTPADDR }, + {"smtpname", required_argument, (int *) 0, LA_SMTPNAME }, {"antispam", required_argument, (int *) 0, LA_ANTISPAM }, {"batchlimit",required_argument, (int *) 0, LA_BATCHLIMIT }, @@ -467,6 +469,9 @@ struct query *ctl; /* option record to be initialized */ case LA_SMTPADDR: ctl->smtpaddress = xstrdup(optarg); break; + case LA_SMTPNAME: + ctl->smtpname = xstrdup(optarg); + break; case 'Z': case LA_ANTISPAM: xalloca(buf, char *, strlen(optarg) + 1); @@ -633,6 +638,7 @@ struct query *ctl; /* option record to be initialized */ #endif /* NET_SECURITY */ P(_(" -S, --smtphost set SMTP forwarding host\n")); P(_(" -D, --smtpaddress set SMTP delivery domain to use\n")); + P(_(" --smtpname set SMTP full name username@domain\n")); P(_(" -Z, --antispam, set antispam response values\n")); P(_(" -b, --batchlimit set batch limit for SMTP connections\n")); P(_(" -B, --fetchlimit set fetch limit for server connections\n")); @@ -525,12 +525,14 @@ int open_sink(struct query *ctl, struct msgblk *msg, for (idp = msg->recipients; idp; idp = idp->next) if (idp->val.status.mark == XMIT_ACCEPT) { - if (strchr(idp->id, '@')) - fprintf(sinkfp, - "RCPT TO: %s\r\n", idp->id); + if (ctl->smtpname) + fprintf(sinkfp, "RCPT TO: %s\r\n", ctl->smtpname); + else if (strchr(idp->id, '@')) + fprintf(sinkfp, + "RCPT TO: %s\r\n", idp->id); else fprintf(sinkfp, - "RCPT TO: %s@%s\r\n", idp->id, ctl->destaddr); + "RCPT TO: %s@%s\r\n", idp->id, ctl->destaddr); *good_addresses = 0; } @@ -768,13 +770,22 @@ int open_sink(struct query *ctl, struct msgblk *msg, { if (strchr(idp->id, '@')) strcpy(addr, idp->id); - else + else { + if (ctl->smtpname) { #ifdef HAVE_SNPRINTF - snprintf(addr, sizeof(addr)-1, "%s@%s", idp->id, ctl->destaddr); + snprintf(addr, sizeof(addr)-1, "%s", ctl->smtpname); #else - sprintf(addr, "%s@%s", idp->id, ctl->destaddr); + sprintf(addr, "%s", ctl->smtpname); #endif /* HAVE_SNPRINTF */ + } else { +#ifdef HAVE_SNPRINTF + snprintf(addr, sizeof(addr)-1, "%s@%s", idp->id, ctl->destaddr); +#else + sprintf(addr, "%s@%s", idp->id, ctl->destaddr); +#endif /* HAVE_SNPRINTF */ + } + } if (SMTP_rcpt(ctl->smtp_socket, addr) == SM_OK) (*good_addresses)++; else |