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 = '';