Hi,

Finally I'm taking a closer look at replacing ssmtp with busybox
sendmail. Attatched is a patch (against 1.12.0) with what i needed to
make it work.

Most serious issue was the fact that current bb sendmail uses the from
address in the EHLO/HELO message. The rfc1869 (section 4.2) says it
should be a domain not an address. So my MTA correctly dicarded the
invalid EHLO. I solved this by using the domain part in the from
address. This requires that the from address has an '@' which i think is
ok in todays world (10 years ago it would be different)

Seconly, I added an -o option thats just ignored. It allows you to be
somewhat compatible: sendmail -oi ...

Third, the enviroment variable HOSTNAME is a "reserverd" variable for
bash so I changed it to SMTPHOST.

Sendmail is a good addition to busybox. Thanks!

-nc
--- busybox-1.12.0.orig/networking/sendmail.c	2008-08-10 20:46:41 +0000
+++ busybox-1.12.0/networking/sendmail.c	2008-09-24 13:37:20 +0000
@@ -319,7 +319,7 @@
 		// save initial stdin since body is piped!
 		xdup2(STDIN_FILENO, INITIAL_STDIN_FILENO);
 		opt_complementary = "w+:a::";
-		options = "w:H:St" "s:c:a:iN:f:";
+		options = "w:H:St" "s:c:a:iN:f:o";
 		// body is pseudo attachment read from stdin
 		llist_add_to_end(&opt_attachments, (char *)"-");
 	} else {
@@ -336,9 +336,9 @@
 	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";
 	}
@@ -381,15 +381,20 @@
 		char *q;
 		llist_t *l;
 		llist_t *headers = NULL;
+		char *domain;
 
 		// got no sender address? -> use username as a resort
 		if (!(opts & OPTS_f)) {
-			char *domain = safe_getdomainname();
+			domain = safe_getdomainname();
 			opt_from = xasprintf("[EMAIL PROTECTED]", opt_user, domain);
 			if (ENABLE_FEATURE_CLEAN_UP)
 				free(domain);
 		}
-
+		domain = strchr(opt_from, '@');
+		if (!domain)
+			bb_error_msg_and_die("no @ in sender");
+		domain++;
+		
 		// introduce to server
 
 		// we didn't use SSL helper? ->
@@ -399,8 +404,8 @@
 		}
 
 		// 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);
 		}
 
 		// set sender
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox

Reply via email to