Dear fetchmail-friends,
My SMTPd [1] is more fussy than most about the syntax of its SMTP
conversation. Normally it is happy with fetchmail, but I have just
noticed this in my logs:
MAIL FROM: <>
500 Syntax error
The problem is that the space is not allowed between the : and the <.
Fetchmail doesn't normally put one there, but it seems that in the case
of <> it does.
I have grepped for MAIL FROM in the source and there seem to be 3
places. sink.c has one that seems to be BSMTP-related. The other two
are in smtp.c in SMTP_from(). It seems to do somthing like this:
if (strchr(from, '<'))
"MAIL FROM: %s", from
else
"MAIL FROM:<%s>", from
SMTP_from() is called from two places in sink.c. send_bouncemail()
passes the host fqdn as the from parameter to SMTP_from(); it won't
contain a < so will take the else path and everything is fine.
The other call to SMTP_from() is from open_smtp_sink(). This considers
various possible values for the from parameter one of which gets
assigned to its ap variable. This all looks OK to me, but I note that
the parameter may or may not have <> around it, which is presumably the
reason for the test in SMTP_from().
However, I can see no reason why SMTP_from() searches for a < using
strchr. If there is a < it must be from[0].
Anyway, I have modified my copy to remove the spaces and change the test
for <, and a patch is attached. Any comments?
Regards,
--Phil.
[1] http://decimail.org/
diff -Naur fetchmail-6.2.5-orig/sink.c fetchmail-6.2.5/sink.c
--- fetchmail-6.2.5-orig/sink.c 2003-10-10 23:06:36.000000000 +0100
+++ fetchmail-6.2.5/sink.c 2004-07-09 16:37:43.000000000 +0100
@@ -724,7 +724,7 @@
/* see the ap computation under the SMTP branch */
fprintf(sinkfp,
- "MAIL FROM: %s", (msg->return_path[0]) ? msg->return_path : user);
+ "MAIL FROM:%s", (msg->return_path[0]) ? msg->return_path : user);
if (ctl->pass8bits || (ctl->mimemsg & MSG_IS_8BIT))
fputs(" BODY=8BITMIME", sinkfp);
diff -Naur fetchmail-6.2.5-orig/smtp.c fetchmail-6.2.5/smtp.c
--- fetchmail-6.2.5-orig/smtp.c 2003-08-06 04:30:18.000000000 +0100
+++ fetchmail-6.2.5/smtp.c 2004-07-09 17:09:04.000000000 +0100
@@ -232,13 +232,13 @@
int ok;
char buf[MSGBUFSIZE];
- if (strchr(from, '<'))
+ if (from[0]=='<')
#ifdef HAVE_SNPRINTF
snprintf(buf, sizeof(buf),
#else
sprintf(buf,
#endif /* HAVE_SNPRINTF */
- "MAIL FROM: %s", from);
+ "MAIL FROM:%s", from);
else
#ifdef HAVE_SNPRINTF
snprintf(buf, sizeof(buf),