- register char *p;
- char buf[MAXLINE+1];
- extern char *index();
- extern char *rindex();
- extern bool sameword();
-
- /* test for inhuman sender */
- p = rindex(from, '@');
- if (p != NULL)
- {
- *p = '\0';
- if (sameword(&p[-8], "-REQUEST") ||
- sameword(&p[-10], "Postmaster") ||
- sameword(&p[-13], "MAILER-DAEMON"))
- {
- *p = '@';
- return (TRUE);
+ 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);