add mail-from option
This commit is contained in:
parent
59f6c2959a
commit
8030a46ca3
2 changed files with 26 additions and 9 deletions
|
@ -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.
|
||||
|
|
16
ddclient.in
16
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=<max> : log at most <max> warning messages for undefined IP address"],
|
||||
["mail", "=s", "--mail=<address> : e-mail messages to <address>"],
|
||||
["mail-failure", "=s", "--mail-failure=<addr> : e-mail messages for failed updates to <addr>"],
|
||||
["mail-from", "=s", "--mail-from=<addr> : send status e-mail messages from <addr>"],
|
||||
["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,11 +2401,24 @@ 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) {
|
||||
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",
|
||||
|
@ -2414,6 +2429,7 @@ sub sendmail {
|
|||
" $program\@$hostname (version $version)"
|
||||
);
|
||||
}
|
||||
}
|
||||
$last_emailbody = $emailbody;
|
||||
$emailbody = '';
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue