+/*
+ * junkmail --
+ * read the header and return if automagic/junk/bulk mail
+ */
+static
+junkmail(from)
+ char *from;
+{
+ static struct ignore {
+ char *name;
+ int len;
+ } ignore[] = {
+ "-REQUEST", 8, "Postmaster", 10,
+ "uucp", 4, "MAILER-DAEMON", 13,
+ "MAILER", 6, NULL, NULL,
+ };
+ register struct ignore *I;
+ register int len;
+ register char *p;
+ char buf[MAXLINE],
+ *index(), *rindex();
+
+ /*
+ * This is mildly amusing, and I'm not positive it's right; what
+ * we're trying to do is find the "real" name of the sender. I'm
+ * assuming that addresses will be some variant of:
+ *
+ * From SENDER
+ * From SENDER@seismo.css.gov
+ * From SENDER%site.BITNET@seismo.css.gov
+ * From site1!site2!SENDER@seismo.css.gov
+ *
+ * Therefore, the following search order:
+ */
+ if (!(p = index(from, '%')))
+ if (!(p = index(from, '@'))) {
+ if (p = rindex(from, '!'))
+ ++p;
+ for (p = from; *p; ++p);
+ }
+ len = p - from;
+ for (I = ignore; I->name; ++I)
+ if (len >= I->len && !strncasecmp(I->name, p - I->len, I->len)) {
+ if (debug)
+ fprintf(stderr, "not sending to %s {%s}\n", from, I->name);
+ return(YES);
+ }
+
+ /* read the header looking for a "Precedence:" line */
+ while (gets(buf) && *buf) {
+ if (strncasecmp(buf, "Precedence", 10) ||
+ buf[10] != ':' && buf[10] != ' ' && buf[10] != '\t')
+ continue;
+
+ /* find the value of this field */
+ if (!(p = index(buf, ':')))
+ continue;
+ while (*++p && isspace(*p));
+ if (!*p)
+ continue;
+
+ /* see if it is "junk" or "bulk" */
+ if (!strncasecmp(p, "junk", 4) || !strncasecmp(p, "bulk", 4)) {
+ if (debug)
+ fprintf(stderr, "not sending to %s {junk/bulk}\n", from);
+ return(YES);
+ }
+ }
+ return(NO);
+}
+
+/*
+ * knows --
+ * find out if user has gotten a vacation message recently.
+ */
+static