[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    smtpsender.patch
From:       Matthew Schumacher <matt.s () aptalaska ! net>
Date:       2021-05-24 15:24:08
Message-ID: 86b075b8-80fb-b79a-779f-1ca592a2939a () aptalaska ! net
[Download RAW message or body]

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 SMTPSENDER=sysadmin@domain.net
echo Starting cron
/usr/sbin/crond -l 6

Or if you are sending email from another script:

SMTPHOST=<forwarding smtp server> SMTPSENDER="sysadmin@domain.net" 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
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic