fixup! add mail-from option

factor out duplicate code
This commit is contained in:
Richard Hansen 2024-12-19 19:31:53 -05:00 committed by Indrajit Raychaudhuri
parent 2de77f17f7
commit d1f81dc9e4

View file

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