]> Pileus Git - ~andy/fetchmail/commitdiff
Try to accomodate spam filtering
authorEric S. Raymond <esr@thyrsus.com>
Sat, 30 Nov 1996 20:10:02 +0000 (20:10 -0000)
committerEric S. Raymond <esr@thyrsus.com>
Sat, 30 Nov 1996 20:10:02 +0000 (20:10 -0000)
svn path=/trunk/; revision=588

Makefile.in
driver.c
fetchmail.h
smtp.c

index ca672d9ede6b99628028415c29688e74b24b9009..159447cd995c2be3ddc6f2fdc24ef2e2ba4a4580 100644 (file)
@@ -4,7 +4,7 @@
 # So just uncomment all the lines marked QNX.
 
 VERS=2.1
-PL=0
+PL=1
 
 # Ultrix 2.2 make doesn't expand the value of VPATH.
 srcdir = @srcdir@
index 70192ac59b468e3d0e24332948ff793551ae7386..c28098b21f88f076ab7fec5b7dc4534c40a703f4 100644 (file)
--- a/driver.c
+++ b/driver.c
@@ -547,10 +547,25 @@ struct query *ctl;        /* query control record */
                 * ID.  This won't affect replies, which use the header
                 * From address anyway.
                 */
-               if (!fromhdr || !(ap = nxtaddr(fromhdr)) 
-                                       || SMTP_from(sinkfp, ap) != SM_OK)
+               if (!fromhdr || !(ap = nxtaddr(fromhdr)))
+               {
                    if (SMTP_from(sinkfp, user) != SM_OK)
                        return(PS_SMTP);        /* should never happen */
+               }
+               else if (SMTP_from(sinkfp, ap) != SM_OK)
+                   if (smtp_response == 571)
+                   {
+                       /*
+                        * SMTP listener explicitly refuses to deliver
+                        * mail coming from this address, probably due
+                        * to an anti-spam domain exclusion.  Respect
+                        * this.
+                        */
+                       sinkfp = (FILE *)NULL;
+                       goto skiptext;
+                   }
+                   else if (SMTP_from(sinkfp, user) != SM_OK)
+                       return(PS_SMTP);        /* should never happen */
 
                /* now list the recipient addressees */
                for (idp = xmit_names; idp; idp = idp->next)
@@ -574,6 +589,8 @@ struct query *ctl;  /* query control record */
                SMTP_data(sinkfp);
                if (outlevel == O_VERBOSE)
                    fputs("SMTP> ", stderr);
+
+           skiptext:;
            }
 
            /* change continuation markers back to regular newlines */
@@ -594,7 +611,7 @@ struct query *ctl;  /* query control record */
            /* write all the headers */
            if (ctl->mda[0])
                n = write(mboxfd,headers,oldlen);
-           else
+           else if (sinkfp)
                n = SockWrite(headers, oldlen, sinkfp);
 
            if (n < 0)
@@ -676,7 +693,7 @@ struct query *ctl;  /* query control record */
        /* ship out the text line */
        if (ctl->mda[0])
            n = write(mboxfd,bufp,strlen(bufp));
-       else
+       else if (sinkfp)
            n = SockWrite(bufp, strlen(bufp), sinkfp);
 
        if (!ctl->mda[0])
index e524e6afdc859d019e894547b7d81c0b37b7298c..8c68e1a07109d72f566b20db9402bf1ac79fdf40 100644 (file)
@@ -156,6 +156,8 @@ extern int linelimit;               /* limit # lines retrieved per site */
 extern int versioninfo;                /* emit only version info */
 extern char *user;             /* name of invoking user */
 
+extern int smtp_response;      /* numeric value of SMTP response code */
+
 /* prototypes for globally callable functions */
 #if defined(HAVE_STDARG_H)
 void gen_send (FILE *sockfp, char *, ... );
diff --git a/smtp.c b/smtp.c
index 77ced235f8eace22941970dcc072d5164e0d9d44..ea75560c61414dc7a3bee905e68ae76b6a8c791e 100644 (file)
--- a/smtp.c
+++ b/smtp.c
@@ -18,6 +18,8 @@
 #include "fetchmail.h"
 #include "smtp.h"
 
+int smtp_response;     /* numeric value of SMTP response code */
+
 int SMTP_helo(FILE *sockfp,char *host)
 /* send a "HELO" message to the SMTP listener */
 {
@@ -112,6 +114,7 @@ static int SMTP_check(FILE *sockfp)
        buf[n] = '\0';
        if (outlevel == O_VERBOSE)
            fprintf(stderr, "SMTP< %s\n", buf);
+       smtp_response = atoi(buf);
        if ((buf[0] == '1' || buf[0] == '2' || buf[0] == '3') && buf[3] == ' ')
            return SM_OK;
        else if (buf[3] != '-')