aboutsummaryrefslogtreecommitdiffstats
path: root/driver.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>1996-11-08 21:38:40 +0000
committerEric S. Raymond <esr@thyrsus.com>1996-11-08 21:38:40 +0000
commit62472c27003c5a45d01d35b7e39f7145fa6dda1d (patch)
treec43cde550995b00396f6a93a19bb00fbd3050c54 /driver.c
parent6206e1a9b3a91f026dbaec45bd421bdf80baa2e3 (diff)
downloadfetchmail-62472c27003c5a45d01d35b7e39f7145fa6dda1d.tar.gz
fetchmail-62472c27003c5a45d01d35b7e39f7145fa6dda1d.tar.bz2
fetchmail-62472c27003c5a45d01d35b7e39f7145fa6dda1d.zip
Cheaper error handling.
svn path=/trunk/; revision=518
Diffstat (limited to 'driver.c')
-rw-r--r--driver.c40
1 files changed, 26 insertions, 14 deletions
diff --git a/driver.c b/driver.c
index 18223d1e..325383ce 100644
--- a/driver.c
+++ b/driver.c
@@ -332,14 +332,15 @@ struct query *ctl; /* query control record */
else if (headers) /* OK, we're at end of headers now */
{
char *cp;
- struct idlist *idp, *xmit_names, *bad_addresses;
+ struct idlist *idp, *xmit_names;
+ int good_addresses, bad_addresses;
#ifdef HAVE_RES_SEARCH
int no_local_matches = FALSE;
#endif /* HAVE_RES_SEARCH */
/* cons up a list of local recipients */
xmit_names = (struct idlist *)NULL;
- bad_addresses = (struct idlist *)NULL;
+ bad_addresses = good_addresses = 0;
#ifdef HAVE_RES_SEARCH
/* is this a multidrop box? */
if (MULTIDROP(ctl))
@@ -436,18 +437,26 @@ struct query *ctl; /* query control record */
}
for (idp = xmit_names; idp; idp = idp->next)
- if (SMTP_rcpt(sinkfp, idp->id) != SM_OK)
+ if (SMTP_rcpt(sinkfp, idp->id) == SM_OK)
+ good_addresses++;
+ else
{
- save_uid(&bad_addresses, -1, idp->id);
+ bad_addresses++;
+ idp->val.num = 0;
fprintf(stderr,
"fetchmail: SMTP listener doesn't like recipient address `%s'\n", idp->id);
}
+ if (!good_addresses && SMTP_rcpt(sinkfp, user) != SM_OK)
+ {
+ fprintf(stderr,
+ "fetchmail: can't even send to calling user!\n");
+ return(PS_SMTP);
+ }
SMTP_data(sinkfp);
if (outlevel == O_VERBOSE)
fputs("SMTP> ", stderr);
}
- free_uid_list(&xmit_names);
/* change continuation markers back to regular newlines */
for (cp = headers; cp < headers + oldlen; cp++)
@@ -502,18 +511,19 @@ struct query *ctl; /* query control record */
#endif /* HAVE_RES_SEARCH */
strcat(errhd, "SMTP listener rejected recipient addresses: ");
errlen = strlen(errhd);
- for (idp = bad_addresses; idp; idp = idp->next)
- errlen += strlen(idp->id) + 2;
+ for (idp = xmit_names; idp; idp = idp->next)
+ if (!idp->val.num)
+ errlen += strlen(idp->id) + 2;
errmsg = alloca(errlen+1);
(void) strcpy(errmsg, errhd);
- for (idp = bad_addresses; idp; idp = idp->next)
- {
- strcat(errmsg, idp->id);
- if (idp->next)
- strcat(errmsg, ", ");
- }
- free_uid_list(&bad_addresses);
+ for (idp = xmit_names; idp; idp = idp->next)
+ if (!idp->val.num)
+ {
+ strcat(errmsg, idp->id);
+ if (idp->next)
+ strcat(errmsg, ", ");
+ }
strcat(errmsg, "\n");
@@ -522,6 +532,8 @@ struct query *ctl; /* query control record */
else
SockWrite(errmsg, strlen(errmsg), sinkfp);
}
+
+ free_uid_list(&xmit_names);
}
/* SMTP byte-stuffing */