crond: add handling of "MAILTO=user" lines
sendmail: handle a case when the whole mail comes from stdin (and no separate sender/subj is provided) both by dronnikov AT gmail.com function old new delta sendgetmail_main 1509 1674 +165 SynchronizeFile 671 767 +96 packed_usage 24054 24088 +34 crond_main 1404 1420 +16 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 4/0 up/down: 311/0) Total: 311 bytes
This commit is contained in:
@ -273,6 +273,7 @@ int sendgetmail_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
|
||||
OPTS_c = 1 << 6, // sendmail: assumed charset
|
||||
OPTS_t = 1 << 7, // sendmail: recipient(s)
|
||||
OPTS_i = 1 << 8, // sendmail: ignore lone dots in message body (implied)
|
||||
};
|
||||
|
||||
const char *options;
|
||||
@ -288,8 +289,8 @@ int sendgetmail_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
// SENDMAIL
|
||||
// save initial stdin (body or attachements can be piped!)
|
||||
xdup2(STDIN_FILENO, INITIAL_STDIN_FILENO);
|
||||
opt_complementary = "-2:w+:t:t::"; // count(-t) > 0
|
||||
options = "w:U:P:X" "ns:c:t:";
|
||||
opt_complementary = "-2:w+:t::";
|
||||
options = "w:U:P:X" "ns:c:t:i";
|
||||
} else {
|
||||
// FETCHMAIL
|
||||
opt_after_connect = NULL;
|
||||
@ -346,6 +347,29 @@ int sendgetmail_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
// get the sender
|
||||
opt_from = sane(*argv++);
|
||||
|
||||
// if no recipients _and_ no body files specified -> enter all-included mode
|
||||
// i.e. scan stdin for To: and Subject: lines ...
|
||||
// ... and then use the rest of stdin as message body
|
||||
if (!opt_recipients && !*argv) {
|
||||
// fetch recipients and (optionally) subject
|
||||
char *s;
|
||||
while ((s = xmalloc_reads(INITIAL_STDIN_FILENO, NULL, NULL)) != NULL) {
|
||||
if (0 == strncmp("To: ", s, 4)) {
|
||||
llist_add_to_end(&opt_recipients, s+4);
|
||||
} else if (0 == strncmp("Subject: ", s, 9)) {
|
||||
opt_subject = s+9;
|
||||
opts |= OPTS_s;
|
||||
} else {
|
||||
char first = s[0];
|
||||
free(s);
|
||||
if (!first)
|
||||
break; // empty line
|
||||
}
|
||||
}
|
||||
// order to read body from stdin
|
||||
*--argv = (char *)"-";
|
||||
}
|
||||
|
||||
// introduce to server
|
||||
// we should start with modern EHLO
|
||||
if (250 != smtp_checkp("EHLO %s", opt_from, -1)) {
|
||||
|
Reference in New Issue
Block a user