Here is another one I've been using for a few years now:

It allows you to define the sender from the ENV.  This combined with SMTPHOST allows you do something like this in cron, which is nice if you don't have the hosts domain in public DNS.

export SMTPHOST=<forwarding smtp server>
export [email protected]
echo Starting cron
/usr/sbin/crond -l 6

Or if you are sending email from another script:

SMTPHOST=<forwarding smtp server> SMTPSENDER="[email protected]" sendmail

diff -ruN busybox-1.27.2.orig/mailutils/sendmail.c busybox-1.27.2/mailutils/sendmail.c --- busybox-1.27.2.orig/mailutils/sendmail.c    2017-07-06 07:14:57.000000000 -0800 +++ busybox-1.27.2/mailutils/sendmail.c    2017-12-20 12:42:28.533957181 -0900
@@ -361,9 +361,13 @@

     // got no sender address? use auth name, then UID username as a last resort
     if (!opt_from) {
-        opt_from = xasprintf("%s@%s",
+        if( getenv("SMTPSENDER") ){
+            opt_from = xasprintf("%s", getenv("SMTPSENDER"));
+        } else {
+            opt_from = xasprintf("%s@%s",
                              G.user ? G.user : xuid2uname(getuid()),
                              xgethostbyname(host)->h_name);
+        }
     }
     free(host);

_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to