From cb5d4bfdede25be56a603a0acd01caabf27eb8cd Mon Sep 17 00:00:00 2001 From: ed neville Date: Tue, 19 Aug 2025 16:30:17 +0100 Subject: [PATCH] get_accountname should use $from_mailbox Additional PBP stern fixes --- VIRTUAL_VACATION/Contributions.txt | 5 +++++ VIRTUAL_VACATION/vacation.pl | 10 +++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/VIRTUAL_VACATION/Contributions.txt b/VIRTUAL_VACATION/Contributions.txt index d8f5f076..59f18c5a 100644 --- a/VIRTUAL_VACATION/Contributions.txt +++ b/VIRTUAL_VACATION/Contributions.txt @@ -103,3 +103,8 @@ Additional authors: Fix handling of the default $smtp_client setthing of 'localhost' if we aren't connecting to the SMTP server on localhost. + +2023-08-18 Ed Neville + Optional /usr/sbin/sendmail, some setups benefit from piped delivery + PBP stern fixes + Minor parameter bugfix in get_accountname diff --git a/VIRTUAL_VACATION/vacation.pl b/VIRTUAL_VACATION/vacation.pl index 097f7f24..d34a2b51 100644 --- a/VIRTUAL_VACATION/vacation.pl +++ b/VIRTUAL_VACATION/vacation.pl @@ -33,6 +33,9 @@ use File::Basename; use Net::DNS; use Time::Piece; +use strict; +use warnings; + # ========== begin configuration ========== # IMPORTANT: If you put passwords into this script, then remember @@ -377,7 +380,7 @@ sub get_accountname { my $query = qq{SELECT name FROM mailbox WHERE username=? }; my $stm = $dbh->prepare($query) or panic_prepare($query); - $stm->execute($to) or panic_execute($query,"username='$from_mailbox'"); + $stm->execute($from_mailbox) or panic_execute($query,"username='$from_mailbox'"); my @row = $stm->fetchrow_array; my $rv = $stm->rows; @@ -566,7 +569,7 @@ sub send_vacation_email { my $resolver = Net::DNS::Resolver->new; my @mx = mx($resolver, $email_domain_part); if (@mx) { - $smtp_server = @mx[0]->exchange; + $smtp_server = $mx[0]->exchange; $logger->debug("Found MX record <$smtp_server> for user <$email>!"); } else { $logger->error("Unable to find MX record for user <$email>, error message: ".$resolver->errorstring); @@ -658,6 +661,7 @@ sub send_vacation_email { } } } + return; } # Convert a (list of) email address(es) from RFC 822 style addressing to @@ -738,7 +742,7 @@ $replyto = ''; $logger->debug("Script argument SMTP recipient is : '$smtp_recipient' and smtp_sender : '$smtp_sender'"); -while () { +while (<>) { last if (/^$/); if (/^\s+(.*)/ and $lastheader) { $$lastheader .= " $1"; next; } elsif (/^from:\s*(.*)\n$/i) { $from = $1; $lastheader = \$from; }