From d32771d1135542b16137c90ec9382294bb98c0ed Mon Sep 17 00:00:00 2001
From: Matthias Andree <matthias.andree@gmx.de>
Date: Tue, 16 Aug 2005 12:45:24 +0000
Subject: Write RFC-compliant BSMTP envelopes. Reported by Nico Golde.

svn path=/trunk/; revision=4237
---
 NEWS   |  1 +
 sink.c | 11 ++++++++---
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/NEWS b/NEWS
index a225672f..07a9aad3 100644
--- a/NEWS
+++ b/NEWS
@@ -173,6 +173,7 @@ fetchmail 6.3.0 (not yet released officially):
 * Switched to automake. Matthias Andree.
 * Got rid of alloca() in fetchmail proper.  Matthias Andree
 * Got rid of ipv6-connect, inner_connect and thereabouts.  Matthias Andree
+* Write RFC-compliant BSMTP envelopes. Reported by Nico Golde. Matthias Andree.
 
 fetchmail-6.2.5 (Wed Oct 15 18:39:22 EDT 2003), 23079 lines:
 
diff --git a/sink.c b/sink.c
index a3c52a5b..5483ca04 100644
--- a/sink.c
+++ b/sink.c
@@ -713,6 +713,7 @@ static int open_bsmtp_sink(struct query *ctl, struct msgblk *msg,
 /* open a BSMTP stream */
 {
     struct	idlist *idp;
+    int		need_anglebrs;
 
     if (strcmp(ctl->bsmtp, "-") == 0)
 	sinkfp = stdout;
@@ -720,8 +721,12 @@ static int open_bsmtp_sink(struct query *ctl, struct msgblk *msg,
 	sinkfp = fopen(ctl->bsmtp, "a");
 
     /* see the ap computation under the SMTP branch */
-    fprintf(sinkfp, 
-	    "MAIL FROM:%s", (msg->return_path[0]) ? msg->return_path : user);
+    need_anglebrs = (msg->return_path[0] != '<');
+    fprintf(sinkfp,
+	    "MAIL FROM:%s%s%s",
+	    need_anglebrs ? "<" : "",
+	    (msg->return_path[0]) ? msg->return_path : user,
+	    need_anglebrs ? ">" : "");
 
     if (ctl->pass8bits || (ctl->mimemsg & MSG_IS_8BIT))
 	fputs(" BODY=8BITMIME", sinkfp);
@@ -746,7 +751,7 @@ static int open_bsmtp_sink(struct query *ctl, struct msgblk *msg,
     for (idp = msg->recipients; idp; idp = idp->next)
 	if (idp->val.status.mark == XMIT_ACCEPT)
 	{
-	    fprintf(sinkfp, "RCPT TO: %s\r\n",
+	    fprintf(sinkfp, "RCPT TO:<%s>\r\n",
 		rcpt_address (ctl, idp->id, 1));
 	    (*good_addresses)++;
 	}
-- 
cgit v1.2.3