sendmail: do not discard all headers
This commit is contained in:
parent
4d0cd28947
commit
38e54f1c13
@ -375,6 +375,7 @@ int sendgetmail_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
const char *p;
|
const char *p;
|
||||||
char *q;
|
char *q;
|
||||||
llist_t *l;
|
llist_t *l;
|
||||||
|
llist_t *headers = NULL;
|
||||||
|
|
||||||
// recipients specified as arguments
|
// recipients specified as arguments
|
||||||
while (*argv) {
|
while (*argv) {
|
||||||
@ -390,6 +391,7 @@ int sendgetmail_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
// N.B. subject read from body has priority
|
// N.B. subject read from body has priority
|
||||||
// over that specified on command line.
|
// over that specified on command line.
|
||||||
// recipients are merged
|
// recipients are merged
|
||||||
|
// N.B. other headers are collected and will be dumped verbatim
|
||||||
if (opts & OPTS_t || !opt_recipients) {
|
if (opts & OPTS_t || !opt_recipients) {
|
||||||
// fetch recipients and (optionally) subject
|
// fetch recipients and (optionally) subject
|
||||||
char *s;
|
char *s;
|
||||||
@ -402,11 +404,12 @@ int sendgetmail_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
*/ } else if (0 == strncmp("Subject: ", s, 9)) {
|
*/ } else if (0 == strncmp("Subject: ", s, 9)) {
|
||||||
opt_subject = s+9;
|
opt_subject = s+9;
|
||||||
opts |= OPTS_s;
|
opts |= OPTS_s;
|
||||||
|
} else if (s[0]) {
|
||||||
|
// misc header
|
||||||
|
llist_add_to_end(&headers, s);
|
||||||
} else {
|
} else {
|
||||||
char first = s[0];
|
|
||||||
free(s);
|
free(s);
|
||||||
if (!first)
|
break; // empty line
|
||||||
break; // empty line
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -476,6 +479,11 @@ int sendgetmail_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
if (opts & OPTS_N)
|
if (opts & OPTS_N)
|
||||||
printf("Disposition-Notification-To: %s\r\n", opt_from);
|
printf("Disposition-Notification-To: %s\r\n", opt_from);
|
||||||
|
|
||||||
|
// put headers we could have preread with -t
|
||||||
|
for (l = headers; l; l = l->link) {
|
||||||
|
printf("%s\r\n", l->data);
|
||||||
|
}
|
||||||
|
|
||||||
// make a random string -- it will delimit message parts
|
// make a random string -- it will delimit message parts
|
||||||
srand(monotonic_us());
|
srand(monotonic_us());
|
||||||
boundary = xasprintf("%d-%d-%d", rand(), rand(), rand());
|
boundary = xasprintf("%d-%d-%d", rand(), rand(), rand());
|
||||||
|
Loading…
Reference in New Issue
Block a user