aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--driver.c18
-rw-r--r--fetchmail-FAQ.html18
-rw-r--r--fetchmail.h1
-rw-r--r--fetchmail.man40
-rw-r--r--options.c11
-rw-r--r--rcfile_l.l1
-rw-r--r--rcfile_y.y5
7 files changed, 83 insertions, 11 deletions
diff --git a/driver.c b/driver.c
index 9fd9aeaa..926af3c1 100644
--- a/driver.c
+++ b/driver.c
@@ -222,16 +222,28 @@ struct query *ctl; /* list of permissible aliases */
struct idlist **xmit_names; /* list of recipient names parsed out */
{
const char *lname;
-
+ int sl;
+ int off = 0;
+
lname = idpair_find(&ctl->localnames, name);
if (!lname && ctl->wildcard)
lname = name;
if (lname != (char *)NULL)
{
+ /*
+ * If the name of the user begins with a
+ * qmail virtual domain prefix, remove
+ * the prefix
+ */
+ if (ctl->server.qvirtual)
+ {
+ sl=strlen(ctl->server.qvirtual);
+ if (!strncasecmp(lname,ctl->server.qvirtual,sl)) off=sl;
+ }
if (outlevel == O_VERBOSE)
- error(0, 0, "mapped %s to local %s", name, lname);
- save_str(xmit_names, XMIT_ACCEPT, lname);
+ error(0, 0, "mapped %s to local %s", name, lname+off);
+ save_str(xmit_names, XMIT_ACCEPT, lname+off);
accept_count++;
}
}
diff --git a/fetchmail-FAQ.html b/fetchmail-FAQ.html
index e2d90ff8..70922df0 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: 1997/10/01 13:43:23 $
+<td width="30%" align=right>$Date: 1997/10/02 03:06:01 $
</table>
<HR>
<H1>Frequently Asked Questions About Fetchmail</H1>
@@ -834,11 +834,11 @@ to set up one fetchmail link to be reliably collect the mail for an
entire domain.<p>
One of the basic features of qmail is the `Delivered-To:' message
-header. Whenever qmail deliver a message to a local mailbox it puts
+header. Whenever qmail delivers a message to a local mailbox it puts
the username and hostname of the envelope recipient on this line. The
major reason for this is to prevent mail loops. <p>
-To set up qmail to batch mail for a disconnected site the isp-mailhost
+To set up qmail to batch mail for a disconnected site the ISP-mailhost
will have normally put that site in its `virtualhosts' control file so
it will add a prefix to all mail addresses for this site. This results
in mail sent to 'username@userhost.userdom.dom.com' having a
@@ -880,6 +880,13 @@ in the alias directory (normally /var/qmail/alias) with the contents:<p>
Note this <em>does</em> require a modern /bin/sh.<p>
+Luca Olivetti adds:<P>
+
+If you aren't using qmail locally, or you don't want to set up the
+alias mechanism described above, you can use the option `<code>qvirtual
+"mbox-userstr-"</code>' in your fetchmail config file to strip the prefix
+from the local user name.<p>
+
<hr>
<h2><a name="T2">T2. How can I use fetchmail with exim?</a></h2><p>
@@ -1210,6 +1217,9 @@ mailbox mean it all ends up with a single envelope address that is
useless for rerouting purposes. You may have to set `<CODE>no
envelope</CODE>' to prevent fetchmail from being bamboozled by this.<p>
+Check also answer <a href="#T1">T1</a> on a reliable way to do multidrop
+delivery if your ISP (or your mail redirection provider) is using qmail.<p>
+
<hr>
<h2><a name="M3">M3. I tried to run a mailing list using multidrop, and I have a mail loop!</a></h2>
@@ -1538,7 +1548,7 @@ will look right.<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: 1997/10/01 13:43:23 $
+<td width="30%" align=right>$Date: 1997/10/02 03:06:01 $
</table>
<P><ADDRESS>Eric S. Raymond <A HREF="mailto:esr@thyrsus.com">&lt;esr@snark.thyrsus.com&gt;</A></ADDRESS>
diff --git a/fetchmail.h b/fetchmail.h
index 56b3c4c6..765e261c 100644
--- a/fetchmail.h
+++ b/fetchmail.h
@@ -90,6 +90,7 @@ struct hostdata /* shared among all user connections to given server */
int preauthenticate; /* preauthentication mode to try */
int timeout; /* inactivity timout in seconds */
char *envelope; /* envelope address list header */
+ char *qvirtual; /* prefix removed from local user id */
flag skip; /* suppress poll in implicit mode? */
flag dns; /* do DNS lookup on multidrop? */
flag uidl; /* use RFC1725 UIDLs? */
diff --git a/fetchmail.man b/fetchmail.man
index ce8581d7..1e304f01 100644
--- a/fetchmail.man
+++ b/fetchmail.man
@@ -357,6 +357,36 @@ special case, `envelope "Received"' enables parsing of sendmail-style
Received lines. This is the default, and it should not be necessary
unless you have globally disabled Received parsing with `no envelope'
in the \fI.fetchmailrc\fR file.
+.TP
+.B -Q, --qvirtual
+(Keyword: qvirtual)
+The string assigned to this option will be removed from the user
+name found in the header specified with the \fIenvelope\fR option.
+This option is useful if you are using
+.I fetchmail
+to collect the mail for an entire domain and your ISP (or your mail
+redirection provider) is using qmail.
+One of the basic features of qmail is the
+.sp
+\&`Delivered-To:'
+.sp
+message header. Whenever qmail delivers a message to a local mailbox
+it puts the username and hostname of the envelope recipient on this
+line. The major reason for this is to prevent mail loops. To set up
+qmail to batch mail for a disconnected site the ISP-mailhost will have
+normally put that site in its `Virtualhosts' control file so it will
+add a prefix to all mail addresses for this site. This results in mail
+sent to 'username@userhost.userdom.dom.com' having a
+\&`Delivered-To:' line of the form:
+.sp
+Delivered-To: mbox-userstr-username@userhost.userdom.dom.com
+.sp
+The ISP can make the 'mbox-userstr-' prefix anything they choose
+but a string matching the user host name is likely.
+By using the option `envelope Delivered-To:' you can make fetchmail reliably
+identify the original envelope recipient, but you have to strip the
+`mbox-userstr-' prefix to deliver to the correct user.
+This is what this option is for.
.SH USER AUTHENTICATION
Every mode except ETRN requires authentication of the client.
@@ -729,6 +759,9 @@ T}
no envelope \& T{
Disable looking for envelope address
T}
+qvirtual -Q T{
+Qmail virtual domain prefix to remove from user name
+T}
aka \& T{
Specify alternate DNS names of mailserver
T}
@@ -1168,8 +1201,13 @@ recipients (including blind-copy recopients) to all receivers of the
messages; it is therefore regarded by some administrators as a
security/privacy problem.
.PP
+A slight variation of the `X-Envelope-To' header is the `Delivered-To' put
+by qmail to avoid mail loops. It will probably prefix the user name with a
+string that normally matches the user's domain. To remove this prefix you
+can use the -Q or `qvirtual' option.
+.PP
Sometimes, unfortunately, neither of these methods works. When they
-both fail, fetchmail must fall back on the contents of To/Cc/Bcc
+all fail, fetchmail must fall back on the contents of To/Cc/Bcc
headers to try to determine recipient addressees -- and these are not
reliable. In particular, mailing-list software often ships mail with
only the list broadcast address in the To header.
diff --git a/options.c b/options.c
index fc610f6b..2a719bda 100644
--- a/options.c
+++ b/options.c
@@ -50,10 +50,11 @@
#define LA_INTERFACE 32
#define LA_MONITOR 33
#define LA_YYDEBUG 34
+#define LA_QVIRTUAL 35
-/* options still left: CDgGhHjJoOqQRTUwWxXYzZ */
+/* options still left: CDgGhHjJoORTUwWxXYzZ */
static const char *shortoptions =
- "?Vcsvd:NqL:f:i:p:UP:A:t:E:u:akKFnl:r:S:b:B:e:m:I:M:y";
+ "?Vcsvd:NqL:f:i:p:UP:A:t:E:Q:u:akKFnl:r:S:b:B:e:m:I:M:y";
static const struct option longoptions[] = {
/* this can be const because all flag fields are 0 and will never get set */
@@ -77,6 +78,7 @@ static const struct option longoptions[] = {
{"auth", required_argument, (int *) 0, LA_AUTHENTICATE},
{"timeout", required_argument, (int *) 0, LA_TIMEOUT },
{"envelope", required_argument, (int *) 0, LA_ENVELOPE },
+ {"qvirtual", required_argument, (int *) 0, LA_QVIRTUAL },
{"user", required_argument, (int *) 0, LA_USERNAME },
{"username", required_argument, (int *) 0, LA_USERNAME },
@@ -238,6 +240,10 @@ struct query *ctl; /* option record to be initialized */
case LA_ENVELOPE:
ctl->server.envelope = xstrdup(optarg);
break;
+ case 'Q':
+ case LA_QVIRTUAL:
+ ctl->server.qvirtual = xstrdup(optarg);
+ break;
case 'u':
case LA_USERNAME:
@@ -371,6 +377,7 @@ struct query *ctl; /* option record to be initialized */
fputs(" -A, --auth authentication type (password or kerberos)\n",stderr);
fputs(" -t, --timeout server nonresponse timeout\n",stderr);
fputs(" -E, --envelope envelope address header\n",stderr);
+ fputs(" -Q, --qvirtual prefix to remove from local user id\n",stderr);
fputs(" -u, --username specify users's login on server\n", stderr);
fputs(" -a, --all retrieve old and new messages\n", stderr);
diff --git a/rcfile_l.l b/rcfile_l.l
index a751f6fc..b6fc9b62 100644
--- a/rcfile_l.l
+++ b/rcfile_l.l
@@ -40,6 +40,7 @@ kerberos_v4 { return KERBEROS4; }
kerberos { return KERBEROS4; }
timeout { return TIMEOUT;}
envelope { return ENVELOPE; }
+qvirtual { return QVIRTUAL; }
user(name)? { return USERNAME; }
pass(word)? { return PASSWORD; }
diff --git a/rcfile_y.y b/rcfile_y.y
index 29a64b0e..69813a0e 100644
--- a/rcfile_y.y
+++ b/rcfile_y.y
@@ -56,7 +56,7 @@ extern char * yytext;
%token DEFAULTS POLL SKIP VIA AKA LOCALDOMAINS PROTOCOL
%token AUTHENTICATE TIMEOUT KPOP KERBEROS4
-%token ENVELOPE USERNAME PASSWORD FOLDER SMTPHOST MDA
+%token ENVELOPE QVIRTUAL USERNAME PASSWORD FOLDER SMTPHOST MDA
%token PRECONNECT POSTCONNECT LIMIT
%token IS HERE THERE TO MAP WILDCARD
%token BATCHLIMIT FETCHLIMIT EXPUNGE
@@ -130,6 +130,7 @@ serv_option : AKA alias_list
| AUTHENTICATE KERBEROS4 {current.server.preauthenticate = A_KERBEROS_V4;}
| TIMEOUT NUMBER {current.server.timeout = $2;}
| ENVELOPE STRING {current.server.envelope = xstrdup($2);}
+ | QVIRTUAL STRING {current.server.qvirtual = xstrdup($2);}
| INTERFACE STRING {
#ifdef linux
interface_parse($2, &current.server);
@@ -396,6 +397,7 @@ static void record_current(void)
FLAG_FORCE(server.preauthenticate);
FLAG_FORCE(server.timeout);
FLAG_FORCE(server.envelope);
+ FLAG_FORCE(server.qvirtual);
FLAG_FORCE(server.skip);
FLAG_FORCE(server.dns);
FLAG_FORCE(server.uidl);
@@ -452,6 +454,7 @@ void optmerge(struct query *h2, struct query *h1)
FLAG_MERGE(server.preauthenticate);
FLAG_MERGE(server.timeout);
FLAG_MERGE(server.envelope);
+ FLAG_MERGE(server.qvirtual);
FLAG_MERGE(server.skip);
FLAG_MERGE(server.dns);
FLAG_MERGE(server.uidl);