Files
scripts/Perl OTRS/Kernel/System/Email/DoNotSendEmail.pm
2024-10-14 00:08:40 +02:00

107 lines
2.7 KiB
Perl

# --
# Copyright (C) 2001-2019 OTRS AG, https://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (GPL). If you
# did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.
# --
package Kernel::System::Email::DoNotSendEmail;
use strict;
use warnings;
our @ObjectDependencies = (
'Kernel::System::CommunicationLog',
'Kernel::System::Log',
);
sub new {
my ( $Type, %Param ) = @_;
# allocate new hash for object
my $Self = {%Param};
bless( $Self, $Type );
# debug
$Self->{Debug} = $Param{Debug} || 0;
$Self->{Type} = 'DoNotSendEmail';
return $Self;
}
sub Send {
my ( $Self, %Param ) = @_;
$Param{CommunicationLogObject}->ObjectLog(
ObjectLogType => 'Message',
Priority => 'Debug',
Key => 'Kernel::System::Email::DoNotSendEmail',
Value => 'Received message for emulated sending without real external connections.',
);
$Param{CommunicationLogObject}->ObjectLog(
ObjectLogType => 'Message',
Priority => 'Debug',
Key => 'Kernel::System::Email::DoNotSendEmail',
Value => 'Validating message contents.',
);
# check needed stuff
for (qw(Header Body ToArray)) {
if ( !$Param{$_} ) {
my $ErrorMessage = "Need $_!";
$Param{CommunicationLogObject}->ObjectLog(
ObjectLogType => 'Message',
Priority => 'Error',
Key => 'Kernel::System::Email::DoNotSendEmail',
Value => $ErrorMessage,
);
return {
Success => 0,
ErrorMessage => $ErrorMessage,
};
}
}
# from
if ( !defined $Param{From} ) {
$Param{From} = '';
}
# recipient
my $ToString = join ', ', @{ $Param{ToArray} };
$Param{CommunicationLogObject}->ObjectLogStart(
ObjectLogType => 'Connection',
);
$Param{CommunicationLogObject}->ObjectLog(
ObjectLogType => 'Connection',
Priority => 'Info',
Key => 'Kernel::System::Email::DoNotSendEmail',
Value => "Sending email from '$Param{From}' to '$ToString'.",
);
$Param{CommunicationLogObject}->ObjectLog(
ObjectLogType => 'Connection',
Priority => 'Info',
Key => 'Kernel::System::Email::DoNotSendEmail',
Value => "Email successfully sent!",
);
$Param{CommunicationLogObject}->ObjectLogStop(
ObjectLogType => 'Connection',
Status => 'Successful',
);
return {
Success => 1,
};
}
1;