]> Pileus Git - ~andy/fetchmail/commitdiff
Added smtpaddress option.
authorEric S. Raymond <esr@thyrsus.com>
Sun, 18 Jan 1998 06:04:54 +0000 (06:04 -0000)
committerEric S. Raymond <esr@thyrsus.com>
Sun, 18 Jan 1998 06:04:54 +0000 (06:04 -0000)
svn path=/trunk/; revision=1592

NEWS
driver.c
fetchmail.c
fetchmail.h
fetchmail.man
options.c
rcfile_l.l
rcfile_y.y
sample.rcfile

diff --git a/NEWS b/NEWS
index 4a6698e0071553b91059f00ceca1ef16e0f5f75b..173b1744a5ad4013a28955ebcbddcbfd1ce958b6 100644 (file)
--- a/NEWS
+++ b/NEWS
 ------------------------------------------------------------------------------
 fetchmail-4.3.6 ()
 * Improved RPM packaging with correct grouping and an icon.
-
-There are 262 people on fetchmail-friends and 102 on fetchmail-announce.
+* Fixed another minor bug in handling of `expunge 0'.
+* Kent Robotti sent a new version of fetchsetup.
+* Scott Burson's tweak to allow USER=postmaster to work.
+* Byrial Jensen's fix to handle NULs in mail correctly.
+* Vojtech Pavlik's fix for simultaneous %F and %T.
+* IMAP code can now deal with untagged responses during CAPABILITY
+  (at least one server issues the motd in a bunch of "* OK {ALERT]" lines
+  in response to the first command after connecting.)
+* New --smtpaddress option from Henning P. Schmiedehausen allows you
+  to force the hostname used in MAIL FROM lines.
+
+There are 281 people on fetchmail-friends and 118 on fetchmail-announce.
 
 fetchmail-4.3.5 (Mon Dec 15 06:07:08 EST 1997)
 * Added Kent Robotti's fetchsetup configuration script.
-* Corrected buggy  handling of `expunge 0'.
+* Corrected buggy handling of `expunge 0'.
 * RFC 1731 GSSAPI support from Brendan Cully <brendan@kublai.com>.
 * We no longer reveal the remotename in fetchmail's Received line, as this
   may be sensitive information.
index cbdad26b962334ce417d330a4dcd27e71fc7926e..c6a4ab99bd01421c4f18d588f5041fc7ef289af0 100644 (file)
--- a/driver.c
+++ b/driver.c
@@ -554,7 +554,7 @@ int num;            /* index of message */
     } *addrchain = NULL, **chainptr = &addrchain;
     char buf[MSGBUFSIZE+1], return_path[MSGBUFSIZE+1]; 
     int        from_offs, ctt_offs, env_offs, next_address;
-    char *headers, *received_for, *desthost, *rcv;
+    char *headers, *received_for, *destaddr, *rcv;
     int n, linelen, oldlen, ch, remaining, skipcount;
     char               *cp;
     struct idlist      *idp, *xmit_names;
@@ -896,7 +896,7 @@ int num;            /* index of message */
            if (idp->val.num == XMIT_ACCEPT)
                good_addresses++;
 
-       desthost = "localhost";
+       destaddr = "localhost";
 
        length = strlen(ctl->mda) + 1;
        before = xstrdup(ctl->mda);
@@ -1129,7 +1129,8 @@ int num;          /* index of message */
         * or MX but not a CNAME.  Some listeners (like exim)
         * enforce this.
         */
-       desthost = ctl->smtphost ? ctl->smtphost : "localhost";
+       destaddr = ctl->smtpaddress ? ctl->smtpaddress : ( ctl->smtphost ? ctl->smtphost : "localhost");
+       
        for (idp = xmit_names; idp; idp = idp->next)
            if (idp->val.num == XMIT_ACCEPT)
            {
@@ -1137,9 +1138,9 @@ int num;          /* index of message */
                    strcpy(addr, idp->id);
                else
 #ifdef HAVE_SNPRINTF
-                   snprintf(addr, sizeof(addr)-1, "%s@%s", idp->id, desthost);
+                   snprintf(addr, sizeof(addr)-1, "%s@%s", idp->id, destaddr);
 #else
-                   sprintf(addr, "%s@%s", idp->id, desthost);
+                   sprintf(addr, "%s@%s", idp->id, destaddr);
 #endif /* HAVE_SNPRINTF */
 
                if (SMTP_rcpt(ctl->smtp_socket, addr) == SM_OK)
@@ -1149,15 +1150,15 @@ int num;                /* index of message */
                    bad_addresses++;
                    idp->val.num = XMIT_ANTISPAM;
                    error(0, 0, 
-                         "SMTP listener doesn't like recipient address `%s'", idp->id);
+                         "SMTP listener doesn't like recipient address `%s@%s'", idp->id, destaddr);
                }
            }
        if (!good_addresses)
        {
 #ifdef HAVE_SNPRINTF
-           snprintf(addr, sizeof(addr)-1, "%s@%s", user,  desthost);
+           snprintf(addr, sizeof(addr)-1, "%s@%s", user, destaddr);
 #else
-           sprintf(addr, "%s@%s", user, desthost);
+           sprintf(addr, "%s@%s", user, destaddr);
 #endif /* HAVE_SNPRINTF */
 
            if (SMTP_rcpt(ctl->smtp_socket, addr) != SM_OK)
@@ -1212,7 +1213,7 @@ int num;          /* index of message */
                {
                    sprintf(buf+1, 
                            "for <%s@%s> (by default); ",
-                           user, desthost);
+                           user, destaddr);
                }
                else if (good_addresses == 1)
                {
@@ -1220,7 +1221,7 @@ int num;          /* index of message */
                        if (idp->val.num == XMIT_ACCEPT)
                            break;      /* only report first address */
                    sprintf(buf+1, "for <%s@%s> (%s); ",
-                           idp->id, desthost,
+                           idp->id, destaddr,
                            MULTIDROP(ctl) ? "multi-drop" : "single-drop");
                }
                else
index 506c11e72d24ecf2499fc7b13a017697b4835d9f..49c163c240c29f4f1cf670e67d18facf2685a2c3 100644 (file)
@@ -578,6 +578,7 @@ static int load_params(int argc, char **argv, int optind)
 
     memset(&def_opts, '\0', sizeof(struct query));
     def_opts.smtp_socket = -1;
+    def_opts.smtpaddress = (char *)0;
 
     def_opts.server.protocol = P_AUTO;
     def_opts.server.timeout = CLIENT_TIMEOUT;
@@ -1012,6 +1013,9 @@ void dump_params (struct query *ctl)
                    printf(" (default)");
            }
        printf("\n");
+       if (ctl->smtpaddress)
+           printf("  Host part of MAIL FROM line will be %s\n",
+                  ctl->smtpaddress);
     }
     if (ctl->preconnect)
        printf("  Server connection will be brought up with '%s.'\n",
index 55162750125083522c3c6518ed0b95deb3c3e1b7..7ded5a4bc8f270e1d4524544b0db9c272b4d44b2 100644 (file)
@@ -129,6 +129,7 @@ struct query
     struct idlist *mailboxes;  /* list of mailboxes to check */
     struct idlist *smtphunt;   /* list of SMTP hosts to try forwarding to */
     char *smtphost;            /* actual SMTP host to point to */
+    char *smtpaddress;         /* address we want to force in the delivery messages */ 
     char *mda;                 /* local MDA to pass mail to */
     char *preconnect;          /* pre-connection command to execute */
     char *postconnect;         /* post-connection command to execute */
index 83cb6f9181717aeef4295ab60c875bc2ba9f9039..0423213748b5bb901169e6d03cb6d6eb29687637 100644 (file)
@@ -209,6 +209,12 @@ 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.
 .TP
+.B \-D domain, --smtpaddress domain
+(Keyword: smtpaddress) 
+Specify the domain to be put in MAIL FROM 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 \-m, \--mda
 (Keyword: mda)
 You can force mail to be passed to an MDA directly (rather than
index 521028ac325c693c3877ebd2ad044c45141ff70a..4d0aa0d125d9fa7d6bc7810a0106153605d272d4 100644 (file)
--- a/options.c
+++ b/options.c
 #define LA_LIMIT       26
 #define LA_FOLDER      27
 #define LA_SMTPHOST    28
-#define LA_BATCHLIMIT  29
-#define LA_FETCHLIMIT  30
-#define LA_EXPUNGE     31
-#define LA_MDA         32
-#define LA_INTERFACE    33
-#define LA_MONITOR      34
-#define LA_YYDEBUG     35
-#define LA_QVIRTUAL     36
+#define LA_SMTPADDR     29
+#define LA_BATCHLIMIT  30
+#define LA_FETCHLIMIT  31
+#define LA_EXPUNGE     32
+#define LA_MDA         33
+#define LA_INTERFACE    34
+#define LA_MONITOR      35
+#define LA_YYDEBUG     36
+#define LA_QVIRTUAL     37
 
-/* options still left: CDgGhHjJoORTUwWxXYzZ */
+/* options still left: CgGhHjJoORTUwWxXYzZ */
 static const char *shortoptions = 
        "?Vcsvd:NqL:f:i:p:UP:A:t:E:Q:u:akKFnl:r:S:b:B:e:m:I:M:y";
 
@@ -94,6 +95,8 @@ 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    },
+  
   {"batchlimit",required_argument, (int *) 0, LA_BATCHLIMIT  },
   {"fetchlimit",required_argument, (int *) 0, LA_FETCHLIMIT  },
   {"expunge",   required_argument, (int *) 0, LA_EXPUNGE     },
@@ -298,6 +301,10 @@ struct query *ctl; /* option record to be initialized */
                ((cp = strtok((char *)NULL, ",")));
            ocount++;
            break;
+    case 'D':
+       case LA_SMTPADDR:
+         ctl->smtpaddress = xstrdup(optarg);
+         break;
        case 'b':
        case LA_BATCHLIMIT:
            c = atoi(optarg);
@@ -390,6 +397,7 @@ struct query *ctl;  /* option record to be initialized */
        fputs("  -l, --limit       don't fetch messages over given size\n", stderr);
 
        fputs("  -S, --smtphost    set SMTP forwarding host\n", stderr);
+       fputs("  -D, --smtpaddress set SMTP delivery domain to use\n", stderr);
        fputs("  -b, --batchlimit  set batch limit for SMTP connections\n", stderr);
        fputs("  -B, --fetchlimit  set fetch limit for server connections\n", stderr);
        fputs("  -e, --expunge     set max deletions between expunges\n", stderr);
index 010190e6638a0c98f2cdce8f4df0a6447d902145..817504f3f2879ac976faf5e1de0d2018639362c6 100644 (file)
@@ -48,6 +48,7 @@ user(name)?   { return USERNAME; }
 pass(word)?    { return PASSWORD; }
 folder(s)?     { return FOLDER; }
 smtp(host)?    { return SMTPHOST; }
+smtpaddress    { return SMTPADDRESS; }
 mda            { return MDA; }
 pre(connect)?  { return PRECONNECT; }
 post(connect)? { return POSTCONNECT; }
index 56195ab9ecee650d9d2c4dc7aa5f8cacd86512c4..9b0573d18ac28e7c7476ddd38e1c835a78e9eae2 100644 (file)
@@ -57,7 +57,7 @@ extern char * yytext;
 
 %token DEFAULTS POLL SKIP VIA AKA LOCALDOMAINS PROTOCOL
 %token AUTHENTICATE TIMEOUT KPOP KERBEROS4
-%token ENVELOPE QVIRTUAL USERNAME PASSWORD FOLDER SMTPHOST MDA
+%token ENVELOPE QVIRTUAL USERNAME PASSWORD FOLDER SMTPHOST MDA SMTPADDRESS
 %token PRECONNECT POSTCONNECT LIMIT
 %token IS HERE THERE TO MAP WILDCARD
 %token BATCHLIMIT FETCHLIMIT EXPUNGE
@@ -223,6 +223,7 @@ user_option : TO localnames HERE
                | PASSWORD STRING       {current.password   = xstrdup($2);}
                | FOLDER folder_list
                | SMTPHOST smtp_list
+               | SMTPADDRESS STRING    {current.smtpaddress = xstrdup($2);}
                | MDA STRING            {current.mda        = xstrdup($2);}
                | PRECONNECT STRING     {current.preconnect = xstrdup($2);}
                | POSTCONNECT STRING    {current.postconnect = xstrdup($2);}
@@ -433,6 +434,7 @@ static void record_current(void)
     if (cmd_opts.smtphunt)
        current.smtphunt = cmd_opts.smtphunt;
     FLAG_FORCE(mda);
+       FLAG_FORCE(smtpaddress);
     FLAG_FORCE(preconnect);
     FLAG_FORCE(postconnect);
 
@@ -487,6 +489,7 @@ void optmerge(struct query *h2, struct query *h1)
     FLAG_MERGE(remotename);
     FLAG_MERGE(password);
     FLAG_MERGE(mda);
+    FLAG_MERGE(smtpaddress);
     FLAG_MERGE(preconnect);
 
     FLAG_MERGE(keep);
index 2250b4d6612a66ec1d0101c32a141ab2b9e2bf68..5f2846315f6a42a4f2f1723065d81e951e17249e 100644 (file)
@@ -44,6 +44,7 @@
 #   folder                    -- must be followed by remote folder names
 #   password (or pass)        -- must be followed by a password string
 #   smtphost (or smtp)        -- must be followed by host names
+#   smtpaddress               -- must be followed by a host name
 #   mda                       -- must be followed by an MDA command string
 #   preconnect (or pre)       -- must be followed by an executable command
 #   postconnect (or post)     -- must be followed by an executable command