diff -Naur busybox.orig/include/usage.h busybox/include/usage.h
--- busybox.orig/include/usage.h	2008-09-25 19:22:15 +0000
+++ busybox/include/usage.h	2008-09-25 22:39:48 +0000
@@ -3466,7 +3466,8 @@
 
 #define sendmail_trivial_usage \
        "[-w timeout] [-H [user:pass@]server[:port]] [-S]\n" \
-       "[-c charset] [-N type] [-i] [-s subject] [-a attach]... [-t] [-f sender] [rcpt]..."
+       "[-c charset] [-N type] [-o] [-i] [-s subject]" \
+       USE_FEATURE_SENDMAIL_ATTACHMENTS(" [-a attach]...") " [-t] [-f sender] [rcpt]..."
 #define sendmail_full_usage "\n\n" \
        "Send an email\n" \
      "\nOptions:" \
@@ -3475,9 +3476,12 @@
      "\n	-S		Use openssl connection helper for secure servers" \
      "\n	-c charset	Assume charset for body and subject (utf-8)" \
      "\n	-N type		Request delivery notification. Type is ignored" \
+     "\n	-o		Ignored for compatibility" \
      "\n	-i		Ignore single dots in mail body. Implied" \
      "\n	-s subject	Subject" \
+	USE_FEATURE_SENDMAIL_ATTACHMENTS( \
      "\n	-a file		File to attach. May be multiple" \
+     	)
      "\n	-t		Read recipients and subject from body" \
      "\n	-f sender	Sender" \
 
diff -Naur busybox.orig/networking/Config.in busybox/networking/Config.in
--- busybox.orig/networking/Config.in	2008-09-04 19:43:36 +0000
+++ busybox/networking/Config.in	2008-09-25 22:37:49 +0000
@@ -687,6 +687,20 @@
 	help
 	  Barebones sendmail.
 
+config FEATURE_SENDMAIL_ATTACHMENTS
+	bool "Allow to send file attachments"
+	default y
+	depends on SENDMAIL
+	help
+	  Allow to send file attachments.
+
+config FEATURE_SENDMAIL_SSL
+	bool "Allow to communicate via SSL/TLS"
+	default y
+	depends on SENDMAIL
+	help
+	  Allow to use secure connections provided by openssl. E.g. @gmail.com.
+
 config FETCHMAIL
 	bool "fetchmail"
 	default n
diff -Naur busybox.orig/networking/sendmail.c busybox/networking/sendmail.c
--- busybox.orig/networking/sendmail.c	2008-09-04 19:43:36 +0000
+++ busybox/networking/sendmail.c	2008-09-25 22:29:28 +0000
@@ -96,6 +96,7 @@
 #define opt_charset	  (fargs[0])
 #define opt_subject	  (fargs[1])
 
+#if ENABLE_FEATURE_SENDMAIL_SSL
 static void kill_helper(void)
 {
 	// TODO!!!: is there more elegant way to terminate child on program failure?
@@ -151,6 +152,7 @@
 	signal_handler(SIGCHLD);
 	// child seems OK -> parent goes on
 }
+#endif
 
 static const char *command(const char *fmt, const char *param)
 {
@@ -187,7 +189,9 @@
 			return n;
 		}
 	}
+#if ENABLE_FEATURE_SENDMAIL_SSL
 	kill_helper();
+#endif
 	bb_error_msg_and_die("%s failed", msg);
 }
 
@@ -224,7 +228,9 @@
 			free(answer);
 		return;
 	}
+#if ENABLE_FEATURE_SENDMAIL_SSL
 	kill_helper();
+#endif
 	bb_error_msg_and_die("%s failed", msg);
 }
 
@@ -283,12 +289,16 @@
 int sendgetmail_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
 int sendgetmail_main(int argc UNUSED_PARAM, char **argv)
 {
+#if ENABLE_FEATURE_SENDMAIL_ATTACHMENTS
 	llist_t *opt_attachments = NULL;
+#endif
 	char *opt_from;
 	const char *opt_user;
 	const char *opt_pass;
+
 	enum {
 		OPT_w = 1 << 0,         // network timeout
+
 		OPT_H = 1 << 1,         // [user:password@]server[:port]
 		OPT_S = 1 << 2,         // connect using openssl s_client helper
 
@@ -304,9 +314,11 @@
 
 		OPTS_N = 1 << 8,        // sendmail: request notification
 		OPTS_f = 1 << 9,        // sendmail: sender address
+		OPTS_o = 1 << 10,       // sendmail: ignored
 	};
 	const char *options;
-	int opts;
+	unsigned opts;
+	FILE *fp0 = fp0;
 
 	// init global variables
 	INIT_G();
@@ -318,10 +330,9 @@
 		// SENDMAIL
 		// save initial stdin since body is piped!
 		xdup2(STDIN_FILENO, INITIAL_STDIN_FILENO);
+		fp0 = fdopen(INITIAL_STDIN_FILENO, "r");
 		opt_complementary = "w+:a::";
-		options = "w:H:St" "s:c:a:iN:f:";
-		// body is pseudo attachment read from stdin
-		llist_add_to_end(&opt_attachments, (char *)"-");
+		options = "w:H:St" "s:c:a:iN:f:o";
 	} else {
 		// FETCHMAIL
 		opt_after_connect = NULL;
@@ -330,15 +341,21 @@
 	}
 	opts = getopt32(argv, options,
 		&timeout /* -w */, &opt_connect /* -H */,
-		&opt_subject, &opt_charset, &opt_attachments, NULL, &opt_from
+		&opt_subject, &opt_charset,
+#if ENABLE_FEATURE_SENDMAIL_ATTACHMENTS
+		&opt_attachments,
+#else
+		NULL,
+#endif
+		NULL, &opt_from
 	);
 	//argc -= optind;
 	argv += optind;
 
 	// connect to server
-	// host[:port] not specified ? -> use $HOSTNAME. no $HOSTNAME ? -> use localhost
+	// host[:port] not specified ? -> use $SMTPHOST. no $SMTPHOST ? -> use localhost
 	if (!(opts & OPT_H)) {
-		opt_connect = getenv("HOSTNAME");
+		opt_connect = getenv("SMTPHOST");
 		if (!opt_connect)
 			opt_connect = "127.0.0.1";
 	}
@@ -355,11 +372,14 @@
 	}
 
 	// SSL ordered? ->
+#if ENABLE_FEATURE_SENDMAIL_SSL
 	if (opts & OPT_S) {
 		// ... use openssl helper
 		launch_helper(xargs);
 	// no SSL ordered? ->
-	} else {
+	} else
+#endif
+	{
 		// ... make plain connect
 		int fd = create_and_connect_stream_or_die(opt_connect, 25);
 		// make ourselves a simple IO filter
@@ -376,32 +396,30 @@
 	{
 		int code;
 		char *boundary;
-		const char *fmt;
-		const char *p;
-		char *q;
 		llist_t *l;
 		llist_t *headers = NULL;
+		char *domain = sane(safe_getdomainname());
 
 		// got no sender address? -> use username as a resort
 		if (!(opts & OPTS_f)) {
-			char *domain = safe_getdomainname();
 			opt_from = xasprintf("%s@%s", opt_user, domain);
-			if (ENABLE_FEATURE_CLEAN_UP)
-				free(domain);
 		}
 
 		// introduce to server
 
 		// we didn't use SSL helper? ->
+#if ENABLE_FEATURE_SENDMAIL_SSL
 		if (!(opts & OPT_S)) {
 			// ... wait for initial server OK
 			smtp_check(NULL, 220);
 		}
-
+#endif
 		// we should start with modern EHLO
-		if (250 != smtp_checkp("EHLO %s", sane(opt_from), -1)) {
-			smtp_checkp("HELO %s", opt_from, 250);
+		if (250 != smtp_checkp("EHLO %s", domain, -1)) {
+			smtp_checkp("HELO %s", domain, 250);
 		}
+		if (ENABLE_FEATURE_CLEAN_UP)
+			free(domain);
 
 		// set sender
 		// NOTE: if password has not been specified
@@ -441,7 +459,7 @@
 		if (opts & OPTS_t || !headers) {
 			// fetch recipients and (optionally) subject
 			char *s;
-			while ((s = xmalloc_reads(INITIAL_STDIN_FILENO, NULL, NULL)) != NULL) {
+			while ((s = xmalloc_fgetline(fp0)) != NULL) {
 				if (0 == strncasecmp("To: ", s, 4) || 0 == strncasecmp("Cc: ", s, 4)) {
 					rcptto(sane(s+4));
 					llist_add_to_end(&headers, s);
@@ -454,14 +472,15 @@
 					opt_from = s+6;
 					opts |= OPTS_f;
 */				} else if (0 == strncmp("Subject: ", s, 9)) {
-					opt_subject = s+9;
-					opts |= OPTS_s;
+					// we read subject -> use it verbatim
+					llist_add_to_end(&headers, s);
+					opts &= ~OPTS_s;
 				} else if (s[0]) {
 					// misc header
 					llist_add_to_end(&headers, s);
 				} else {
 					free(s);
-					break; // empty line
+					break; // stop on the first empty line
 				}
 			}
 		}
@@ -496,58 +515,92 @@
 		srand(monotonic_us());
 		boundary = xasprintf("%d-%d-%d", rand(), rand(), rand());
 
-		// put common headers and body start
-		printf(
-			"Message-ID: <%s>\r\n"
-			"Mime-Version: 1.0\r\n"
-			"%smultipart/mixed; boundary=\"%s\"\r\n"
-			, boundary
-			, "Content-Type: "
-			, boundary
-		);
-
-		// put body + attachment(s)
-		// N.B. all these weird things just to be tiny
-		// by reusing string patterns!
-		fmt =
-			"\r\n--%s\r\n"
-			"%stext/plain; charset=%s\r\n"
-			"%s%s\r\n"
-			"%s"
-		;
-		p = opt_charset;
-		q = (char *)"";
-		l = opt_attachments;
-		while (l) {
+		// put common headers
+		// TODO: do we really need this?
+//		printf("Message-ID: <%s>\r\n", boundary);
+
+#if ENABLE_FEATURE_SENDMAIL_ATTACHMENTS
+		// have attachments? -> compose multipart MIME
+		if (opt_attachments) {
+			const char *fmt;
+			const char *p;
+			char *q;
+
 			printf(
-				fmt
-				, boundary
+				"Mime-Version: 1.0\r\n"
+				"%smultipart/mixed; boundary=\"%s\"\r\n"
 				, "Content-Type: "
-				, p
-				, "Content-Disposition: inline"
-				, q
-				, "Content-Transfer-Encoding: base64\r\n"
+				, boundary
 			);
-			p = "";
+
+			// body is pseudo attachment read from stdin in first turn
+			llist_add_to(&opt_attachments, (char *)"-");
+
+			// put body + attachment(s)
+			// N.B. all these weird things just to be tiny
+			// by reusing string patterns!
 			fmt =
 				"\r\n--%s\r\n"
-				"%sapplication/octet-stream%s\r\n"
-				"%s; filename=\"%s\"\r\n"
+				"%stext/plain; charset=%s\r\n"
+				"%s%s\r\n"
 				"%s"
 			;
-			uuencode(l->data, NULL);
-			l = l->link;
-			if (l)
-				q = bb_get_last_path_component_strip(l->data);
-		}
+			p = opt_charset;
+			q = (char *)"";
+			l = opt_attachments;
+			while (l) {
+				printf(
+					fmt
+					, boundary
+					, "Content-Type: "
+					, p
+					, "Content-Disposition: inline"
+					, q
+					, "Content-Transfer-Encoding: base64\r\n"
+				);
+				p = "";
+				fmt =
+					"\r\n--%s\r\n"
+					"%sapplication/octet-stream%s\r\n"
+					"%s; filename=\"%s\"\r\n"
+					"%s"
+				;
+				uuencode(l->data, NULL);
+				l = l->link;
+				if (l)
+					q = bb_get_last_path_component_strip(l->data);
+			}
 
-		// put message terminator
-		printf("\r\n--%s--\r\n" "\r\n", boundary);
+			// put message terminator
+			printf("\r\n--%s--\r\n" "\r\n", boundary);
+
+		// no attachments? -> just dump message
+		} else
+#endif
+		{
+			char *s;
+			// terminate headers
+			printf("\r\n");
+			// put plain text respecting leading dots
+			while ((s = xmalloc_fgetline(fp0)) != NULL) {
+				// escape leading dots
+				// N.B. this feature is implied even if no -i switch given
+				// N.B. we need to escape the leading dot regardless of
+				// whether it is single or not character on the line
+				if ( /*(opts & OPTS_i) && */ '.' == s[0] /*&& '\0' == s[1] */)
+					printf(".");
+				// dump read line
+				printf("%s\r\n", s);
+			}
+		}
 
 		// leave "put message" mode
 		smtp_check(".", 250);
 		// ... and say goodbye
 		smtp_check("QUIT", 221);
+		// cleanup
+		if (ENABLE_FEATURE_CLEAN_UP)
+			fclose(fp0);
 	}
 #if ENABLE_FETCHMAIL
 /***************************************************
@@ -671,5 +724,5 @@
 	}
 #endif // ENABLE_FETCHMAIL
 
-	return 0;
+	return EXIT_SUCCESS;
 }
