From: Ken Hornstein Date: Thu, 23 Aug 2012 14:08:59 +0000 (-0400) Subject: Change the Bcc: code in post so it includes the From: header from the original X-Git-Url: http://git.marmaro.de/?a=commitdiff_plain;h=783f7afc3d5817828604b7f441d9de45b80f9aa6;p=mmh Change the Bcc: code in post so it includes the From: header from the original message. --- diff --git a/Makefile.am b/Makefile.am index 9e94b4d..5fc505e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -63,6 +63,7 @@ TESTS = test/ali/test-ali \ test/new/test-basic \ test/pick/test-pick test/pick/test-stderr \ test/post/test-post-basic test/post/test-post-multiple \ + test/post/test-post-bcc \ test/post/test-post-dcc test/post/test-post-fcc \ test/post/test-post-multifrom test/post/test-post-envelope \ test/post/test-post-group test/post/test-mts test/post/test-messageid \ diff --git a/test/post/test-mts b/test/post/test-mts index 6011549..18250b1 100755 --- a/test/post/test-mts +++ b/test/post/test-mts @@ -148,6 +148,7 @@ This is a test EOF cat > "${testname}.expected2" < Date: Subject: Test diff --git a/test/post/test-post-bcc b/test/post/test-post-bcc new file mode 100755 index 0000000..e1a6354 --- /dev/null +++ b/test/post/test-post-bcc @@ -0,0 +1,85 @@ +#!/bin/sh +# +# Test the behavior of post with multiple recipients and the use of Bcc: +# + +set -e + +if test -z "${MH_OBJ_DIR}"; then + srcdir=`dirname "$0"`/../.. + MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR +fi + +. "${srcdir}/test/post/test-post-common.sh" + +# +# Bcc test. +# +# It's worth pointing out here what's going on the SMTP protocol. +# +# If there are both sighted and unsighted addresses in the address list, +# post calls verify_all_addresses() which results in ALL recipient +# addresses being attempted, then the SMTP connection is reset, then +# both the sighted and unsigned messages are sent (in different SMTP +# transactions). Apparantly post has always done it this way. +# + +cat > "${MH_TEST_DIR}/Mail/draft" < +To: Somebody One , + Somebody Two +Subject: Test Bcc +Bcc: Somebody Three , + Somebody Four + +This is test of Bcc recipients. +EOF + +cat > "${testname}.expected" < +RCPT TO: +RCPT TO: +RCPT TO: +RCPT TO: +RSET +MAIL FROM: +RCPT TO: +RCPT TO: +DATA +From: Mr Nobody +To: Somebody One , + Somebody Two +Subject: Test Bcc +Date: + +This is test of Bcc recipients. +. +RSET +MAIL FROM: +RCPT TO: +RCPT TO: +DATA +From: Mr Nobody +Date: +Subject: Test Bcc +BCC: + +------- Blind-Carbon-Copy + +From: Mr Nobody +To: Somebody One , + Somebody Two +Subject: Test Bcc +Date: + +This is test of Bcc recipients. + +------- End of Blind-Carbon-Copy +. +QUIT +EOF + +test_post "${testname}.actual" "${testname}.expected" + +exit ${failed:-0} diff --git a/uip/post.c b/uip/post.c index 813d462..526b5e4 100644 --- a/uip/post.c +++ b/uip/post.c @@ -262,6 +262,7 @@ static char bccfil[BUFSIZ]; static char from[BUFSIZ]; /* my network address */ static char sender[BUFSIZ]; /* my Sender: header */ static char efrom[BUFSIZ]; /* my Envelope-From: header */ +static char fullfrom[BUFSIZ]; /* full contents of From header */ static char signature[BUFSIZ]; /* my signature */ static char *filter = NULL; /* the filter for BCC'ing */ static char *subject = NULL; /* the subject field for BCC'ing */ @@ -900,6 +901,23 @@ putfmt (char *name, char *str, FILE *out) mnfree (mp); } + /* + * If this is a From:/Resent-From: header, save the full thing for + * later in case we need it for use when constructing a Bcc draft message + */ + + if ((msgstate == RESENT) ? (hdr->set & MRFM) : (hdr->set & MFRM)) { + strncpy(fullfrom, str, sizeof(fullfrom)); + fullfrom[sizeof(fullfrom) - 1] = 0; + /* + * Strip off any trailing newlines + */ + + while (strlen(fullfrom) > 0 && fullfrom[strlen(fullfrom) - 1] == '\n') { + fullfrom[strlen(fullfrom) - 1] = '\0'; + } + } + if (grp > 0 && (hdr->flags & HNGR)) { advise (NULL, "%s: field does not allow groups", name); badmsg++; @@ -928,6 +946,7 @@ start_headers (void) from[0] = '\0'; efrom[0] = '\0'; sender[0] = '\0'; + fullfrom[0] = '\0'; if ((cp = getfullname ()) && *cp) { strncpy (sigbuf, cp, sizeof(sigbuf)); @@ -1281,6 +1300,7 @@ make_bcc_file (int dashstuff) if (tfile == NULL) adios("bcc", "unable to create temporary file"); strncpy (bccfil, tfile, sizeof(bccfil)); + fprintf (out, "From: %s\n", fullfrom); fprintf (out, "Date: %s\n", dtime (&tclock, 0)); if (msgid) fprintf (out, "Message-ID: %s\n", message_id (tclock, 0));