field is required in this case. Otherwise a \*(lqSender:\*(rq field
is optional.
.PP
-When using SMTP for mail submission, the envelope\-from used for SMTP
-transaction is derived from the \*(lqFrom:\*(rq field. If multiple
-addresses are in the \*(lqFrom:\*(rq field, the address in the
-\*(lqSender\*(rq field is used instead. This behavior can be overridden
-by using the \*(lqEnvelope\-From:\*(rq field. When \*(lqEnvelope\-From\*(rq
-appears in the message, its address will be used as the SMTP envelope\-from
-address and the field will be removed from the message.
+If a message with multiple \*(lqFrom:\*(rq
+addresses does
+.B NOT
+include a \*(lqSender:\*(rq field but does include an \*(lqEnvelope\-From:\*(rq
+field, the \*(lqEnvelope\-From:\*(rq field will be used to construct
+a \*(lqSender:\*(rq field.
+.PP
+When using SMTP for mail submission, the envelope\-from used for the SMTP
+transaction is derived from the \*(lqEnvelope\-From:\*(rq field.
+If no \*(lqEnvelope\-From:\*(rq field is present, the \*(lqSender:\*(rq
+field is used. If neither the \*(lqEnvelope\-From:\*(rq nor the
+\*(lqSender:\*(rq field is present, the \*(lqFrom:\*(rq field is used.
+When \*(lqEnvelope\-From:\*(rq appears in a message
+it will be removed from the final outgoing message.
.PP
By using the
.B \-format
#define FCCS 10 /* max number of fccs allowed */
-#define uptolow(c) ((isalpha(c) && isupper (c)) ? tolower (c) : c)
-
/* In the following array of structures, the numeric second field of the
structures (minchars) is apparently used like this:
#define HNIL 0x0100 /* okay for this header not to have addrs */
#define HIGN 0x0200 /* ignore this header */
#define HDCC 0x0400 /* another undocumented feature */
-#define HONE 0x0800 /* Only one address allowed */
+#define HONE 0x0800 /* Only (zero or) one address allowed */
#define HEFM 0x1000 /* Envelope-From: header */
/*
* address for SMTP.
*
* - If we were given an Envelope-From header, use that.
- * - If we were given multiple addresses in the From: header, use
- * the Sender: address
+ * - If we were given a Sender: address, use that.
* - Otherwise, use the address on the From: line
*/
if (msgflags & MEFM) {
envelope = efrom;
- } else if (fromcount > 1) {
+ } else if (seensender) {
envelope = sender;
} else {
envelope = from;
if (hdr->flags & HNIL)
fprintf (out, "%s: %s", name, str);
else {
+ /*
+ * Sender (or Resent-Sender) can have only one address
+ */
+ if ((msgstate == RESENT) ? (hdr->set & MRSN)
+ : (hdr->set & MSND)) {
+ advise (NULL, "%s: field requires one address", name);
+ badmsg++;
+ }
#ifdef notdef
advise (NULL, "%s: field requires at least one address", name);
badmsg++;
start_headers (void)
{
unsigned char *cp;
- char myhost[BUFSIZ], sigbuf[BUFSIZ];
+ char sigbuf[BUFSIZ];
struct mailname *mp;
myuid = getuid ();
mygid = getgid ();
time (&tclock);
- strncpy (from, getlocaladdr(), sizeof(from));
- strncpy (myhost, LocalName (0), sizeof(myhost));
+ /*
+ * Probably not necessary, but just in case ...
+ */
- for (cp = myhost; *cp; cp++)
- *cp = uptolow (*cp);
+ from[0] = '\0';
+ efrom[0] = '\0';
+ sender[0] = '\0';
if ((cp = getfullname ()) && *cp) {
strncpy (sigbuf, cp, sizeof(sigbuf));
advise (NULL, "message has no From: header");
advise (NULL, "See default components files for examples");
badmsg++;
+ break;
}
- if (fromcount > 1 && seensender == 0) {
- advise (NULL, "A Sender: header is required with multiple "
- "From: addresses");
+ if (fromcount > 1 && (seensender == 0 && !(msgflags & MEFM))) {
+ advise (NULL, "A Sender: or Envelope-From: header is required "
+ "with multiple\nFrom: addresses");
badmsg++;
+ break;
}
if (whomsw)
if (msgid)
fprintf (out, "Message-ID: <%d.%ld@%s>\n",
(int) getpid (), (long) tclock, LocalName (1));
+ /*
+ * If we have multiple From: addresses, make sure we have an
+ * Sender: header. If we don't have one, then generate one
+ * from Envelope-From: (which in this case, cannot be blank)
+ */
+
+ if (fromcount > 1 && seensender == 0) {
+ if (efrom[0] == '\0') {
+ advise (NULL, "Envelope-From cannot be blank when there "
+ "is multiple From: addresses\nand no Sender: "
+ "header");
+ badmsg++;
+ } else {
+ fprintf (out, "Sender: %s\n", efrom);
+ }
+ }
+
if (!(msgflags & MVIS))
fprintf (out, "Bcc: Blind Distribution List: ;\n");
break;
advise (NULL, "message has no Resent-From: header");
advise (NULL, "See default components files for examples");
badmsg++;
+ break;
}
- if (fromcount > 1 && seensender == 0) {
- advise (NULL, "A Resent-Sender: header is required with "
- "multiple Resent-From: addresses");
+ if (fromcount > 1 && (seensender == 0 && !(msgflags & MEFM))) {
+ advise (NULL, "A Resent-Sender: or Envelope-From: header is "
+ "required with multiple\nResent-From: addresses");
badmsg++;
+ break;
}
if (whomsw)
if (msgid)
fprintf (out, "Resent-Message-ID: <%d.%ld@%s>\n",
(int) getpid (), (long) tclock, LocalName (1));
+ /*
+ * If we have multiple Resent-From: addresses, make sure we have an
+ * Resent-Sender: header. If we don't have one, then generate one
+ * from Envelope-From (which in this case, cannot be blank)
+ */
+
+ if (fromcount > 1 && seensender == 0) {
+ if (efrom[0] == '\0') {
+ advise (NULL, "Envelope-From cannot be blank when there "
+ "is multiple Resent-From: addresses and no "
+ "Resent-Sender: header");
+ badmsg++;
+ } else {
+ fprintf (out, "Resent-Sender: %s\n", efrom);
+ }
+ }
+
if (!(msgflags & MVIS))
fprintf (out, "Resent-Bcc: Blind Re-Distribution List: ;\n");
break;