]> Pileus Git - ~andy/fetchmail/commitdiff
Accept MX and canonical names in Received lines.
authorEric S. Raymond <esr@thyrsus.com>
Wed, 18 Dec 1996 00:16:25 +0000 (00:16 -0000)
committerEric S. Raymond <esr@thyrsus.com>
Wed, 18 Dec 1996 00:16:25 +0000 (00:16 -0000)
svn path=/trunk/; revision=655

driver.c

index a39f989b49f4b76b2eee935b4eefc4f1921257d3..1cebf770c61fae4b5322b8fb03f438c8e6c928fe 100644 (file)
--- a/driver.c
+++ b/driver.c
@@ -422,22 +422,40 @@ struct query *ctl;        /* query control record */
                 * Try to extract the real envelope addressee.  We look here
                 * specifically for the mailserver's Received line.
                 * Note: this will only work for sendmail, or an MTA that
-                * shares sendmail's convention of embedding the envelope
-                * address in the Received line.
+                * shares sendmail's convention for embedding the envelope
+                * address in the Received line.  Sendmail itself only
+                * does this when the mail has a single recipient.
                 */
-               strcpy(rbuf, "by ");
-               strcat(rbuf, ctl->canonical_name);
-               if ((ok = strstr(bufp, rbuf)))
-                   ok = strstr(ok, "for <");
-               else
+               if ((ok = strstr(bufp, "by ")) == (char *)NULL)
                    ok = (char *)NULL;
+               else
+               {
+                   char        *sp, *tp;
+
+                   /* extract space-delimited token after "by " */
+                   tp = rbuf;
+                   for (sp = ok + 3; !isspace(*sp); sp++)
+                       *tp++ = *sp;
+                   *tp = '\0';
+
+                   /*
+                    * If it's a DNS name of the mail server, look for the
+                    * recipient name after a following "for".  Otherwise
+                    * punt.
+                    */
+                   if (is_host_alias(rbuf, ctl))
+                       ok = strstr(sp, "for ");
+                   else
+                       ok = (char *)NULL;
+               }
+
                if (ok != 0)
                {
                    char        *sp, *tp;
 
                    tp = rbuf;
                    sp = ok + 4;
-                   if (*sp == '<')
+                   if (*ok == '<')
                        sp++;
                    while (*sp && *sp != '>' && *sp != '@' && *sp != ';')
                        if (!isspace(*sp))