From d1f81dc9e4a6d4d397706e23278dacce4aedbfeb Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Thu, 19 Dec 2024 19:31:53 -0500 Subject: [PATCH] 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 = '';