summaryrefslogtreecommitdiff
path: root/networking/sendmail.c
diff options
context:
space:
mode:
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)) {