diff -Naur sendmail-8.12.11/sendmail/deliver.c sendmail-8.12.11-bx0.4/sendmail/deliver.c --- sendmail-8.12.11/sendmail/deliver.c 2003-09-26 20:26:19.000000000 +0200 +++ sendmail-8.12.11-bx0.4/sendmail/deliver.c 2004-05-18 18:45:37.000000000 +0200 @@ -3224,7 +3224,22 @@ */ putfromline(mci, e); - (*e->e_puthdr)(mci, e->e_header, e, M87F_OUTER); + +#if DEVEL_DEBUG +if (tTd(99, 1)) +{ +ADDRESS *dadp, *dalp; +sm_dprintf("DEVEL_DEBUG: Sending to unclever mailer\n"); +for (dadp = tochain; dadp != NULL; dadp = dadp->q_tchain) +{ +sm_dprintf(" recpt: Address \"%s\"\n",dadp->q_paddr); +for (dalp = dadp->q_alias; dalp != NULL; dalp = dalp->q_alias) +sm_dprintf(" Alias of \"%s\"\n",dalp->q_paddr); +} +} +#endif /* DEVEL_DEBUG */ + + (*e->e_puthdr)(mci, e->e_header, e, M87F_OUTER, tochain); (*e->e_putbody)(mci, e, NULL); /* get the exit status */ @@ -3338,7 +3353,7 @@ else { e->e_to = tobuf + 1; - rcode = smtpdata(m, mci, e, ctladdr, xstart); + rcode = smtpdata(m, mci, e, ctladdr, xstart, tochain); } } if (rcode == EX_TEMPFAIL && nummxhosts > hostnum) @@ -5504,7 +5519,7 @@ #endif /* MIME7TO8 */ putfromline(&mcibuf, e); - (*e->e_puthdr)(&mcibuf, e->e_header, e, M87F_OUTER); + (*e->e_puthdr)(&mcibuf, e->e_header, e, M87F_OUTER, ctladdr); (*e->e_putbody)(&mcibuf, e, NULL); putline("\n", &mcibuf); if (sm_io_flush(f, SM_TIME_DEFAULT) != 0 || diff -Naur sendmail-8.12.11/sendmail/headers.c sendmail-8.12.11-bx0.4/sendmail/headers.c --- sendmail-8.12.11/sendmail/headers.c 2003-10-30 01:17:22.000000000 +0100 +++ sendmail-8.12.11-bx0.4/sendmail/headers.c 2004-05-19 21:19:32.000000000 +0200 @@ -1419,6 +1419,13 @@ ** hdr -- the header to put. ** e -- envelope to use. ** flags -- MIME conversion flags. +** addr -- any recipient address. Will only be used (to +** provide an (X-)X-Envelope-To: header) when we're +** outputting *message* headers to a mailer with +** M_MUSER *NOT* set. Have caller pass a NULL if +** you positively know that no such header should be +** added (dead.letter, per-MIME-part headers, appen- +** ding headers of original email to a bounce, ...). ** ** Returns: ** none. @@ -1428,11 +1435,12 @@ */ void -putheader(mci, hdr, e, flags) +putheader(mci, hdr, e, flags, addr) register MCI *mci; HDR *hdr; register ENVELOPE *e; int flags; + ADDRESS *addr; { register HDR *h; char buf[SM_MAX(MAXLINE,BUFSIZ)]; @@ -1449,7 +1457,35 @@ */ if (!bitset(MCIF_INMIME, mci->mci_flags)) + { mci->mci_flags |= MCIF_INHEADER; +#if !_BOC_X_ENVELOPE_TO + if (!bitnset(M_MUSER, mci->mci_mailer->m_flags) +#if !_FFR_X_X_ENVELOPE_TO + && bitnset(M_LOCALMAILER, mci->mci_mailer->m_flags) +#endif /* !_FFR_X_X_ENVELOPE_TO */ + && addr != NULL) + { + ADDRESS *ascan; + + for (ascan = addr; ascan->q_alias != NULL; ascan = ascan->q_alias) ; + if (ascan->q_paddr != NULL) + { + (void) sm_snprintf(obuf, sizeof obuf, +#if _FFR_X_X_ENVELOPE_TO + "%sX-Envelope-To: %s%s%s", + (bitnset(M_LOCALMAILER, mci->mci_mailer->m_flags)?"":"X-"), +#else + "X-Envelope-To: %s%s%s", +#endif /*_FFR_X_X_ENVELOPE_TO */ + (ascan->q_paddr[0]=='<'?"":"<"), + ascan->q_paddr, + (ascan->q_paddr[0]=='<'?"":">")); + putline(obuf, mci); + } + } +#endif /* !_BOC_X_ENVELOPE_TO */ + } for (h = hdr; h != NULL; h = h->h_link) { diff -Naur sendmail-8.12.11/sendmail/mime.c sendmail-8.12.11-bx0.4/sendmail/mime.c --- sendmail-8.12.11/sendmail/mime.c 2004-01-08 22:42:56.000000000 +0100 +++ sendmail-8.12.11-bx0.4/sendmail/mime.c 2004-05-13 21:07:31.000000000 +0200 @@ -325,7 +325,7 @@ collect(e->e_dfp, false, &hdr, e, false); if (tTd(43, 101)) putline("+++after collect", mci); - putheader(mci, hdr, e, flags); + putheader(mci, hdr, e, flags, NULL); if (tTd(43, 101)) putline("+++after putheader", mci); bt = mime8to7(mci, hdr, e, boundaries, flags); @@ -379,7 +379,7 @@ collect(e->e_dfp, false, &hdr, e, false); if (tTd(43, 101)) putline("+++after collect", mci); - putheader(mci, hdr, e, flags); + putheader(mci, hdr, e, flags, NULL); if (tTd(43, 101)) putline("+++after putheader", mci); if (hvalue("MIME-Version", hdr) == NULL && diff -Naur sendmail-8.12.11/sendmail/savemail.c sendmail-8.12.11-bx0.4/sendmail/savemail.c --- sendmail-8.12.11/sendmail/savemail.c 2002-10-23 17:08:47.000000000 +0200 +++ sendmail-8.12.11-bx0.4/sendmail/savemail.c 2004-05-13 21:10:32.000000000 +0200 @@ -428,7 +428,7 @@ macdefine(&e->e_macro, A_PERM, 'g', e->e_sender); putfromline(&mcibuf, e); - (*e->e_puthdr)(&mcibuf, e->e_header, e, M87F_OUTER); + (*e->e_puthdr)(&mcibuf, e->e_header, e, M87F_OUTER, NULL); (*e->e_putbody)(&mcibuf, e, NULL); putline("\n", &mcibuf); /* XXX EOL from FileMailer? */ (void) sm_io_flush(fp, SM_TIME_DEFAULT); @@ -1298,7 +1298,7 @@ } putline("", mci); save_errno = errno; - putheader(mci, e->e_parent->e_header, e->e_parent, M87F_OUTER); + putheader(mci, e->e_parent->e_header, e->e_parent, M87F_OUTER, NULL); errno = save_errno; if (sendbody) putbody(mci, e->e_parent, e->e_msgboundary); diff -Naur sendmail-8.12.11/sendmail/sendmail.h sendmail-8.12.11-bx0.4/sendmail/sendmail.h --- sendmail-8.12.11/sendmail/sendmail.h 2003-11-07 01:08:02.000000000 +0100 +++ sendmail-8.12.11-bx0.4/sendmail/sendmail.h 2004-05-13 21:27:35.000000000 +0200 @@ -864,7 +864,7 @@ short e_sendmode; /* message send mode */ short e_errormode; /* error return mode */ short e_timeoutclass; /* message timeout class */ - void (*e_puthdr)__P((MCI *, HDR *, ENVELOPE *, int)); + void (*e_puthdr)__P((MCI *, HDR *, ENVELOPE *, int, ADDRESS *)); /* function to put header of message */ void (*e_putbody)__P((MCI *, ENVELOPE *, char *)); /* function to put body of message */ @@ -966,7 +966,7 @@ extern void clrsessenvelope __P((ENVELOPE *)); extern void printenvflags __P((ENVELOPE *)); extern void putbody __P((MCI *, ENVELOPE *, char *)); -extern void putheader __P((MCI *, HDR *, ENVELOPE *, int)); +extern void putheader __P((MCI *, HDR *, ENVELOPE *, int, ADDRESS *)); /* ** Message priority classes. @@ -2360,7 +2360,7 @@ #if SASL extern int smtpauth __P((MAILER *, MCI *, ENVELOPE *)); #endif /* SASL */ -extern int smtpdata __P((MAILER *, MCI *, ENVELOPE *, ADDRESS *, time_t)); +extern int smtpdata __P((MAILER *, MCI *, ENVELOPE *, ADDRESS *, time_t, ADDRESS *)); extern int smtpgetstat __P((MAILER *, MCI *, ENVELOPE *)); extern int smtpmailfrom __P((MAILER *, MCI *, ENVELOPE *)); extern void smtpmessage __P((char *, MAILER *, MCI *, ...)); diff -Naur sendmail-8.12.11/sendmail/usersmtp.c sendmail-8.12.11-bx0.4/sendmail/usersmtp.c --- sendmail-8.12.11/sendmail/usersmtp.c 2003-05-06 01:51:47.000000000 +0200 +++ sendmail-8.12.11-bx0.4/sendmail/usersmtp.c 2004-05-13 21:30:40.000000000 +0200 @@ -2490,6 +2490,9 @@ ** m -- mailer being sent to. ** mci -- the mailer connection information. ** e -- the envelope for this message. +** (Something missing here?? - JoB) +** addr -- any recipient address. See putheader(). +** (Does smtpdata() actually get used for LMTP?) ** ** Returns: ** exit status corresponding to DATA command. @@ -2499,12 +2502,13 @@ static SM_EVENT *volatile DataTimeout = NULL; int -smtpdata(m, mci, e, ctladdr, xstart) +smtpdata(m, mci, e, ctladdr, xstart, addr) MAILER *m; register MCI *mci; register ENVELOPE *e; ADDRESS *ctladdr; time_t xstart; + ADDRESS *addr; { register int r; int rstat; @@ -2655,7 +2659,7 @@ ** Output the actual message. */ - (*e->e_puthdr)(mci, e->e_header, e, M87F_OUTER); + (*e->e_puthdr)(mci, e->e_header, e, M87F_OUTER, addr); if (tTd(18, 101)) {