diff --git a/ChangeLog.md b/ChangeLog.md index 4c5cc80..a8135ad 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -5,6 +5,11 @@ repository history](https://github.com/ddclient/ddclient/commits/main). ## v4.0.0-rc.2 (unreleased work-in-progress) +### New features + + * New `--mail-from` option to control the "From:" header of email messages. + [#565](https://github.com/ddclient/ddclient/pull/565) + ## 2024-12-25 v4.0.0-rc.1 ### Breaking changes diff --git a/ddclient.conf.in b/ddclient.conf.in index dd4189e..62a7ee9 100644 --- a/ddclient.conf.in +++ b/ddclient.conf.in @@ -25,6 +25,9 @@ daemon=300 # check every 300 seconds syslog=yes # log update msgs to syslog mail=root # mail all msgs to root mail-failure=root # mail failed update msgs to root +# mail-from=root # set the email "From:" header to "root". If + # unset (the default) or empty, the from address + # depends on your system's default behavior. pid=@runstatedir@/ddclient.pid # record PID in file. # postscript=script # run script after updating. The new IP is # added as argument. diff --git a/ddclient.in b/ddclient.in index b37eed3..ebd0e71 100755 --- a/ddclient.in +++ b/ddclient.in @@ -704,6 +704,7 @@ our %cfgvars = ( 'priority' => setv(T_STRING,0, 'notice', undef), 'mail' => setv(T_EMAIL, 0, undef, undef), 'mail-failure' => setv(T_EMAIL, 0, undef, undef), + 'mail-from' => setv(T_EMAIL, 0, undef, undef), 'max-warn' => setv(T_NUMBER,0, 1, undef), 'exec' => setv(T_BOOL, 0, 1, undef), @@ -1427,6 +1428,7 @@ my @opt = ( ["max-warn", "=i", "--max-warn= : log at most warning messages for undefined IP address"], ["mail", "=s", "--mail=
: e-mail messages to
"], ["mail-failure", "=s", "--mail-failure= : e-mail messages for failed updates to "], + ["mail-from", "=s", '--mail-from= : set the "From:" header in e-mail messages to if non-empty'], ["exec", "!", "--{no}exec : do {not} execute; just show what would be done"], ["debug", "!", "--{no}debug : print {no} debugging information"], ["verbose", "!", "--{no}verbose : print {no} verbose information"], @@ -2404,8 +2406,10 @@ sub sendmail { $recipients = opt('mail-failure'); } if ($emailbody && $recipients && $emailbody ne $last_emailbody) { + my $sender = opt('mail-from') // ''; pipecmd("sendmail -oi $recipients", "To: $recipients", + $sender ne '' ? ("From: $sender") : (), "Subject: status report from $program\@$hostname", "\r\n", $emailbody,