* 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)
SMTP_data(sinkfp);
if (outlevel == O_VERBOSE)
fputs("SMTP> ", stderr);
+
+ skiptext:;
}
/* change continuation markers back to regular newlines */
/* 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)
/* 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])
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 *, ... );
#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 */
{
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] != '-')