Skip to content

Commit

Permalink
Merge pull request #486 from csware/cleanup
Browse files Browse the repository at this point in the history
Cleanup
  • Loading branch information
DavidGoodwin committed May 7, 2021
2 parents 97623e9 + 600c375 commit bff4afa
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions VIRTUAL_VACATION/vacation.pl
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
our $smtp_authpwd = '';

# This specifies the mail 'from' name which is shown to recipients of vacation replies.
# If you leave it empty, the vacation mail will contain:
# If you leave it empty, the vacation mail will contain:
# From: <original@recipient.domain>
# If you specify something here you'd instead see something like :
# From: Some Friendly Name <original@recipient.domain>
Expand Down Expand Up @@ -104,7 +104,7 @@
# be answered when $custom_noreply_pattern is set to 1.
# default = 0
our $custom_noreply_pattern = 0;
our $noreply_pattern = 'bounce|do-not-reply|facebook|linkedin|list-|myspace|twitter';
our $noreply_pattern = 'bounce|do-not-reply|facebook|linkedin|list-|myspace|twitter';

# Never send vacation mails for the following recipient email addresses.
# Useful for e.g. aliases pointing to multiple recipients which have vacation active
Expand All @@ -113,7 +113,7 @@
# default = ''
# preventing vacation notifications for recipient info@example.org would look like this:
# our $no_vacation_pattern = 'info\@example\.org';
our $no_vacation_pattern = 'info\@example\.org';
our $no_vacation_pattern = 'info\@example\.org';


# instead of changing this script, you can put your settings to /etc/mail/postfixadmin/vacation.conf
Expand Down Expand Up @@ -159,7 +159,7 @@
$appender->layout($log_layout);
$logger->add_appender($appender);
$logger->debug('Test mode enabled');

} else {
$logger = get_logger();
if($log_to_file == 1) {
Expand Down Expand Up @@ -220,7 +220,7 @@
my $loopcount=0;

#
# Get interval_time for email user from the vacation table
# Get interval_time for email user from the vacation table
#
sub get_interval {
my ($to) = @_;
Expand Down Expand Up @@ -312,7 +312,7 @@ sub already_notified {
}

#
# Check to see if there is a vacation record against a specific email address.
# Check to see if there is a vacation record against a specific email address.
#
sub check_for_vacation {
my ($email_to_check) =@_;
Expand Down Expand Up @@ -438,17 +438,17 @@ sub send_vacation_email {
}

$logger->debug("Will send vacation response for $orig_messageid: FROM: $email (orig_to: $orig_to), TO: $orig_from; VACATION SUBJECT: $row[0] ; VACATION BODY: $row[1]");

my $subject = $row[0];
$subject = Encode::decode_utf8( $subject ) if( !Encode::is_utf8( $subject ) );
$subject = Encode::decode_utf8($subject) if (!Encode::is_utf8($subject));
$orig_subject = decode("mime-header", $orig_subject);
$subject =~ s/\$SUBJECT/$orig_subject/g;
if ($subject ne $row[0]) {
$logger->debug("Patched Subject of vacation message to: $subject");
}

my $body = $row[1];
$body = Encode::decode_utf8( $body ) if( !Encode::is_utf8( $body ) );
$body = Encode::decode_utf8($body) if (!Encode::is_utf8($body));

my $from = $email;
my $to = $orig_from;
Expand All @@ -458,13 +458,13 @@ sub send_vacation_email {

my $resolver = Net::DNS::Resolver->new;
my @mx = mx($resolver, $email_domain_part);
my $smtp_server;
my $smtp_server;
if (@mx) {
$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);
exit(0);
exit(0);
}

my $smtp_params = {
Expand All @@ -487,8 +487,8 @@ sub send_vacation_email {

my $transport = Email::Sender::Transport::SMTP->new($smtp_params);

$subject = Encode::encode_utf8( $subject ) if( Encode::is_utf8( $subject ) );
$body = Encode::encode_utf8( $body ) if( Encode::is_utf8( $body ) );
$subject = Encode::encode_utf8($subject) if(Encode::is_utf8($subject));
$body = Encode::encode_utf8($body) if(Encode::is_utf8($body));
$email = Email::Simple->create(
header => [
To => $to,
Expand Down Expand Up @@ -644,9 +644,9 @@ sub check_and_clean_from_address {
}
$logger->debug("Email headers have to: '$to' and From: '$from'");

if ($to =~ /^.*($no_vacation_pattern).*/i) {
if ($to =~ /^.*($no_vacation_pattern).*/i) {
$logger->debug("Will not send vacation reply for messages to $to");
exit(0);
exit(0);
}

$to = strip_address($to);
Expand Down

0 comments on commit bff4afa

Please sign in to comment.