1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
|
# --
# Copyright (C) 2001-2021 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;
|