summaryrefslogtreecommitdiff
path: root/networking/sendmail.c
diff options
context:
space:
mode:
authorDenis Vlasenko2008-04-07 21:02:35 +0000
committerDenis Vlasenko2008-04-07 21:02:35 +0000
commit6fa1ba3972ddba2216c216236dbc878b9fa8752a (patch)
tree3217321efa202b860229408b60c57d47bc0cdb8f /networking/sendmail.c
parent90c31b3d4b58512ec2e1ed00670668dd52236415 (diff)
downloadbusybox-6fa1ba3972ddba2216c216236dbc878b9fa8752a.zip
busybox-6fa1ba3972ddba2216c216236dbc878b9fa8752a.tar.gz
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
Diffstat (limited to 'networking/sendmail.c')
-rw-r--r--networking/sendmail.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/networking/sendmail.c b/networking/sendmail.c
index 973d712..242bb0e 100644
--- a/networking/sendmail.c
+++ b/networking/sendmail.c
@@ -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)) {