From 8030a46ca396ccc6d9eac3739987287907040849 Mon Sep 17 00:00:00 2001 From: Joel Beckmeyer Date: Fri, 18 Aug 2023 10:00:20 -0400 Subject: [PATCH 1/7] add mail-from option --- ddclient.conf.in | 1 + ddclient.in | 34 +++++++++++++++++++++++++--------- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/ddclient.conf.in b/ddclient.conf.in index dd4189e..fc89163 100644 --- a/ddclient.conf.in +++ b/ddclient.conf.in @@ -25,6 +25,7 @@ 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 # send mail from root, by default unset and handled by system sendmail 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..3def280 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), '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= : send status e-mail messages from "], ["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"], @@ -2399,20 +2401,34 @@ sub logger { } sub sendmail { my $recipients = opt('mail'); + my $sender = opt('mail-from'); if (opt('mail-failure') && ($result ne 'OK' && $result ne '0')) { $recipients = opt('mail-failure'); } if ($emailbody && $recipients && $emailbody ne $last_emailbody) { - pipecmd("sendmail -oi $recipients", - "To: $recipients", - "Subject: status report from $program\@$hostname", - "\r\n", - $emailbody, - "", - "-- ", # https://en.wikipedia.org/wiki/Signature_block#Standard_delimiter - " $program\@$hostname (version $version)" - ); + if ($sender) { + pipecmd("sendmail -oi $recipients", + "To: $recipients", + "From: $sender", + "Subject: status report from $program\@$hostname", + "\r\n", + $emailbody, + "", + "-- ", # https://en.wikipedia.org/wiki/Signature_block#Standard_delimiter + " $program\@$hostname (version $version)" + ); + } else { + pipecmd("sendmail -oi $recipients", + "To: $recipients", + "Subject: status report from $program\@$hostname", + "\r\n", + $emailbody, + "", + "-- ", # https://en.wikipedia.org/wiki/Signature_block#Standard_delimiter + " $program\@$hostname (version $version)" + ); + } } $last_emailbody = $emailbody; $emailbody = ''; From a2e818d6d311ce671bbfbfe230341cb8274e0e6b Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Thu, 19 Dec 2024 19:30:05 -0500 Subject: [PATCH 2/7] fixup! add mail-from option refine usage wording --- ddclient.conf.in | 4 +++- ddclient.in | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ddclient.conf.in b/ddclient.conf.in index fc89163..62a7ee9 100644 --- a/ddclient.conf.in +++ b/ddclient.conf.in @@ -25,7 +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 # send mail from root, by default unset and handled by system sendmail +# 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 3def280..07524c3 100755 --- a/ddclient.in +++ b/ddclient.in @@ -1428,7 +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= : send status e-mail messages from "], + ["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"], From 2de77f17f706f43cdc2e5e57833488c5653f1ce4 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Thu, 19 Dec 2024 19:30:43 -0500 Subject: [PATCH 3/7] fixup! add mail-from option default to undef --- ddclient.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ddclient.in b/ddclient.in index 07524c3..fd4af81 100755 --- a/ddclient.in +++ b/ddclient.in @@ -704,7 +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), + 'mail-from' => setv(T_EMAIL, 0, undef, undef), 'max-warn' => setv(T_NUMBER,0, 1, undef), 'exec' => setv(T_BOOL, 0, 1, undef), @@ -2401,7 +2401,7 @@ sub logger { } sub sendmail { my $recipients = opt('mail'); - my $sender = opt('mail-from'); + my $sender = opt('mail-from') // ''; if (opt('mail-failure') && ($result ne 'OK' && $result ne '0')) { $recipients = opt('mail-failure'); From d1f81dc9e4a6d4d397706e23278dacce4aedbfeb Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Thu, 19 Dec 2024 19:31:53 -0500 Subject: [PATCH 4/7] fixup! add mail-from option factor out duplicate code --- ddclient.in | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/ddclient.in b/ddclient.in index fd4af81..1043dce 100755 --- a/ddclient.in +++ b/ddclient.in @@ -2407,28 +2407,16 @@ sub sendmail { $recipients = opt('mail-failure'); } if ($emailbody && $recipients && $emailbody ne $last_emailbody) { - if ($sender) { - pipecmd("sendmail -oi $recipients", - "To: $recipients", - "From: $sender", - "Subject: status report from $program\@$hostname", - "\r\n", - $emailbody, - "", - "-- ", # https://en.wikipedia.org/wiki/Signature_block#Standard_delimiter - " $program\@$hostname (version $version)" - ); - } else { - pipecmd("sendmail -oi $recipients", - "To: $recipients", - "Subject: status report from $program\@$hostname", - "\r\n", - $emailbody, - "", - "-- ", # https://en.wikipedia.org/wiki/Signature_block#Standard_delimiter - " $program\@$hostname (version $version)" - ); - } + pipecmd("sendmail -oi $recipients", + "To: $recipients", + $sender ne '' ? ("From: $sender") : (), + "Subject: status report from $program\@$hostname", + "\r\n", + $emailbody, + "", + "-- ", # https://en.wikipedia.org/wiki/Signature_block#Standard_delimiter + " $program\@$hostname (version $version)" + ); } $last_emailbody = $emailbody; $emailbody = ''; From d2b1a4dfa6c9394634338bb73474b7ea4c49ce48 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Thu, 19 Dec 2024 19:33:27 -0500 Subject: [PATCH 5/7] fixup! add mail-from option move variable declaration closer to usage --- ddclient.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddclient.in b/ddclient.in index 1043dce..ebd0e71 100755 --- a/ddclient.in +++ b/ddclient.in @@ -2401,12 +2401,12 @@ sub logger { } sub sendmail { my $recipients = opt('mail'); - my $sender = opt('mail-from') // ''; if (opt('mail-failure') && ($result ne 'OK' && $result ne '0')) { $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") : (), From 76fccba1510a8ebe15c5bcdbf4b7626c663fa4a4 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Thu, 19 Dec 2024 19:42:03 -0500 Subject: [PATCH 6/7] fixup! add mail-from option add changelog entry --- ChangeLog.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index 4c5cc80..81ba17c 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -55,6 +55,8 @@ repository history](https://github.com/ddclient/ddclient/commits/main). ### New features + * New `--mail-from` option to control the "From:" header of email messages. + [#565](https://github.com/ddclient/ddclient/pull/565) * Simultaneous/separate updating of IPv4 (A) records and IPv6 (AAAA) records is now supported in the following services: `gandi` ([#558](https://github.com/ddclient/ddclient/pull/558)), `nsupdate` From cf4bad127dd9dd03d9ec3d194530e2e33f940622 Mon Sep 17 00:00:00 2001 From: Indrajit Raychaudhuri Date: Mon, 6 Jan 2025 20:21:53 -0600 Subject: [PATCH 7/7] fixup! add main-from option move changelog entry to v4.0.0-rc.2 --- ChangeLog.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 81ba17c..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 @@ -55,8 +60,6 @@ repository history](https://github.com/ddclient/ddclient/commits/main). ### New features - * New `--mail-from` option to control the "From:" header of email messages. - [#565](https://github.com/ddclient/ddclient/pull/565) * Simultaneous/separate updating of IPv4 (A) records and IPv6 (AAAA) records is now supported in the following services: `gandi` ([#558](https://github.com/ddclient/ddclient/pull/558)), `nsupdate`