static char *subject = NULL; /* the subject field for BCC'ing */
static char fccs[BUFSIZ] = "";
struct mailname *bccs = NULL; /* list of the bcc recipients */
+struct mailname *sender = NULL;
static struct headers *hdrtab; /* table for the message we're doing */
static FILE *out; /* output (temp) file */
if (hdr->set & MFRM) {
struct mailname *mp = NULL;
+ struct mailname *my = NULL;
+ unsigned int fromcnt = 0;
/* This is need because the addresse parser hold global state */
ismymbox(NULL);
while ((cp = getname(str)) != NULL) {
+ fromcnt++;
mp = getm(cp, NULL, 0, AD_NAME, NULL);
if (ismymbox(mp)) {
msgflags |= MFMM;
+ if (my == NULL) {
+ my = mp;
+ } else {
+ mnfree(mp);
+ mp = NULL;
+ }
+ } else {
+ mnfree(mp);
+ mp = NULL;
}
}
+
+ if (fromcnt > 1) {
+ sender = my;
+ } else {
+ mnfree(my);
+ }
+
+ free(cp);
+ cp = NULL;
+
}
if (hdr->flags & HSUB) {
fprintf(out, "%sDate: %s\n", resentstr, dtimenow());
}
- if ((cp = context_find("Default-From")) != NULL) {
+ if (sender != NULL) {
+ snprintf(signature, sizeof(signature), "%s", sender->m_text);
+ } else if ((cp = context_find("Default-From")) != NULL) {
snprintf(signature, sizeof(signature), "%s", cp);
} else {
snprintf(from, sizeof(from), "%s@%s", getusername(), LocalName());
** Add a Sender: header because the From: header could
** be fake or contain multiple addresses.
*/
- if (!(msgflags & MFMM)) {
+ if (!(msgflags & MFMM) || sender != NULL) {
fprintf(out, "%sSender: %s\n", resentstr, signature);
}
}