X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=uip%2Fpost.c;h=6b0786192c4be04df52d3dcc1346b03a4097d3af;hb=9719b1f53abb51d3ed532f875534a2ce3a1d7fde;hp=08c62ebe3113f0eee5c4011f9787349270405604;hpb=84b65bad347129f751e3ed208516697bc3fe1820;p=mmh diff --git a/uip/post.c b/uip/post.c index 08c62eb..6b07861 100644 --- a/uip/post.c +++ b/uip/post.c @@ -131,6 +131,10 @@ static struct swit switches[] = { { "fileproc", -4 }, #define MHLPROCSW 39 { "mhlproc", -3 }, +#define MTSSW 40 + { "mts smtp|sendmail/smtp|sendmail/pipe", 2 }, +#define MESSAGEIDSW 41 + { "messageid localname|random", 2 }, { NULL, 0 } }; @@ -258,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 */ @@ -518,6 +523,19 @@ main (int argc, char **argv) adios (NULL, "missing argument to %s", argp[-2]); mhlproc = cp; continue; + + case MTSSW: + if (!(cp = *argp++) || *cp == '-') + adios (NULL, "missing argument to %s", argp[-2]); + save_mts_method (cp); + continue; + + case MESSAGEIDSW: + if (!(cp = *argp++) || *cp == '-') + adios (NULL, "missing argument to %s", argp[-2]); + if (save_message_id_style (cp) != 0) + adios (NULL, "unsupported messageid \"%s\"", cp); + continue; } } if (msg) @@ -691,7 +709,21 @@ putfmt (char *name, char *str, FILE *out) } if ((i = get_header (name, hdrtab)) == NOTOK) { - fprintf (out, "%s: %s", name, str); + if (strncasecmp (name, "nmh-", 4)) { + fprintf (out, "%s: %s", name, str); + } else { + /* Filter out all Nmh-* headers, because Norm asked. They + should never have reached this point. Warn about any + that are non-empty. */ + if (strcmp (str, "\n")) { + char *newline = strchr (str, '\n'); + if (newline) *newline = '\0'; + if (! whomsw) { + advise (NULL, "ignoring header line -- %s: %s", name, str); + } + } + } + return; } @@ -822,8 +854,22 @@ putfmt (char *name, char *str, FILE *out) else if (mp->m_gname) putgrp (namep, mp->m_gname, out, hdr->flags); - if (mp->m_ingrp) + if (mp->m_ingrp) { + if (sm_mts == MTS_SENDMAIL_PIPE) { + /* Catch this before sendmail chokes with: + "553 List:; syntax illegal for recipient + addresses". + If we wanted to, we could expand out blind + aliases and put them in Bcc:, but then + they'd have the Blind-Carbon-Copy + indication. */ + adios (NULL, + "blind lists not compatible with" + " sendmail/pipe"); + } + grp++; + } if (putadr (namep, qp, mp, out, hdr->flags)) msgflags |= (hdr->set & (MVIS | MINV)); else @@ -883,6 +929,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++; @@ -911,6 +974,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)); @@ -962,8 +1026,7 @@ finish_headers (FILE *out) fprintf (out, "Date: %s\n", dtime (&tclock, 0)); if (msgid) - fprintf (out, "Message-ID: <%d.%ld@%s>\n", - (int) getpid (), (long) tclock, LocalName (1)); + fprintf (out, "Message-ID: %s\n", message_id (tclock, 0)); /* * If we have multiple From: addresses, make sure we have an * Sender: header. If we don't have one, then generate one @@ -1012,8 +1075,8 @@ finish_headers (FILE *out) fprintf (out, "Resent-Date: %s\n", dtime (&tclock, 0)); if (msgid) - fprintf (out, "Resent-Message-ID: <%d.%ld@%s>\n", - (int) getpid (), (long) tclock, LocalName (1)); + fprintf (out, "Resent-Message-ID: %s\n", + message_id (tclock, 0)); /* * If we have multiple Resent-From: addresses, make sure we have an * Resent-Sender: header. If we don't have one, then generate one @@ -1263,13 +1326,12 @@ make_bcc_file (int dashstuff) tfile = m_mktemp2(NULL, "bccs", NULL, &out); if (tfile == NULL) adios("bcc", "unable to create temporary file"); - chmod (bccfil, 0600); 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: <%d.%ld@%s>\n", - (int) getpid (), (long) tclock, LocalName (1)); + fprintf (out, "Message-ID: %s\n", message_id (tclock, 0)); if (subject) fprintf (out, "Subject: %s", subject); fprintf (out, "BCC:\n"); @@ -1472,11 +1534,10 @@ do_addresses (int bccque, int talk) static void post (char *file, int bccque, int talk, char *envelope) { - int fd, onex; + int fd; int retval, i; pid_t child_id; - onex = !(msgflags & MINV) || bccque; if (verbose) { if (msgflags & MINV) printf (" -- Posting for %s Recipients --\n", @@ -1503,7 +1564,6 @@ post (char *file, int bccque, int talk, char *envelope) argp = sargv; *argp++ = "sendmail"; - *argp++ = "-m"; /* send to me too */ *argp++ = "-t"; /* read msg for recipients */ *argp++ = "-i"; /* don't stop on "." */ if (whomsw) @@ -1521,7 +1581,7 @@ post (char *file, int bccque, int talk, char *envelope) } } else { if (rp_isbad (retval = sm_init (clientsw, serversw, port, watch, - verbose, snoop, onex, queued, sasl, + verbose, snoop, queued, sasl, saslssf, saslmech, user, tls)) || rp_isbad (retval = sm_winit (envelope))) die (NULL, "problem initializing server; %s", rp_string (retval)); @@ -1533,7 +1593,7 @@ post (char *file, int bccque, int talk, char *envelope) close (fd); fflush (stdout); - sm_end (onex ? OK : DONE); + sm_end (!(msgflags & MINV) || bccque ? OK : DONE); sigoff (); if (verbose) { @@ -1561,7 +1621,7 @@ verify_all_addresses (int talk, char *envelope) if (!whomsw || checksw) if (rp_isbad (retval = sm_init (clientsw, serversw, port, watch, - verbose, snoop, 0, queued, sasl, + verbose, snoop, queued, sasl, saslssf, saslmech, user, tls)) || rp_isbad (retval = sm_winit (envelope))) die (NULL, "problem initializing server; %s", rp_string (retval));