From e548ae37e99cb88e3466ff0aba2eb18e63d11627 Mon Sep 17 00:00:00 2001 From: ed neville Date: Sun, 17 Aug 2025 15:59:26 +0100 Subject: [PATCH] option for delivery via /usr/sbin/sendmail In some setups it is more convenient to use /usr/sbin/sendmail for delivery sendmail_bin should reference a local binary for which the mail can be piped to. --- VIRTUAL_VACATION/vacation.pl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/VIRTUAL_VACATION/vacation.pl b/VIRTUAL_VACATION/vacation.pl index cf7177d0..097f7f24 100644 --- a/VIRTUAL_VACATION/vacation.pl +++ b/VIRTUAL_VACATION/vacation.pl @@ -60,6 +60,8 @@ our $recipient_delimiter = '+'; our $smtp_server = 'localhost'; # port to connect to; defaults to 25 for non-SSL, 465 for 'ssl', 587 for 'starttls' our $smtp_server_port = 25; +# path to sendmail binary if you prefer to deliver rather than TCP, MUST start with / e.g. /usr/sbin/sendmail +our $sendmail_bin = ''; # this is the local address to connect from our $smtp_client = 'localhost'; @@ -639,7 +641,15 @@ sub send_vacation_email { } try { - sendmail($email, { transport => $transport }); + if ($sendmail_bin =~ m|^/| ) { + $logger->info("delivering via $sendmail_bin from $email_from to $to"); + my $pid = open(my $fh, "|-", $sendmail_bin, "-f", $email_from, $to); + print $fh $email->as_string; + close($fh); + } + else { + sendmail($email, { transport => $transport }); + } } finally { if (@_) { $logger->error("Failed to send vacation response to $to from $from subject $subject: @_");