diff options
author | Eric S. Raymond <esr@thyrsus.com> | 1996-12-18 00:16:25 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 1996-12-18 00:16:25 +0000 |
commit | fff83f3df76ebb49a18309de1c37d0988b0d2629 (patch) | |
tree | 68d4487ebd9846b387237754d7d1bd3b2c666c71 /driver.c | |
parent | 2a62923f7956a2759963eb107baa4290987231ee (diff) | |
download | fetchmail-fff83f3df76ebb49a18309de1c37d0988b0d2629.tar.gz fetchmail-fff83f3df76ebb49a18309de1c37d0988b0d2629.tar.bz2 fetchmail-fff83f3df76ebb49a18309de1c37d0988b0d2629.zip |
Accept MX and canonical names in Received lines.
svn path=/trunk/; revision=655
Diffstat (limited to 'driver.c')
-rw-r--r-- | driver.c | 34 |
1 files changed, 26 insertions, 8 deletions
@@ -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)) |