Posting this again!
I have written up a little addon to crythias' code that also sends a notification email to whomever you want. It also includes in an attachment the body and subject of the blocked incoming email.
1st Section: You need to add the email object definition in the 'sub new'
FILE: OTRS/Kernel/System/PostMaster/NewTicket.pm
Code: Select all
# get all objects
for (qw(DBObject ConfigObject TicketObject LogObject ParserObject TimeObject QueueObject)) {
$Self->{$_} = $Param{$_} || die 'Got no $_';
}
$Self->{CustomerUserObject} = Kernel::System::CustomerUser->new(%Param);
$Self->{EmailObject} = Kernel::System::Email->new(%Param);
return $Self;
2nd Section: You add the Email Object and fill out the details
Code: Select all
# if there is no customer user found!
if ( !$GetParam{'X-OTRS-CustomerUser'} ) {
$GetParam{'X-OTRS-CustomerUser'} = $GetParam{SenderEmailAddress};
# First we write the issue to log, then we send out an email! - MichaelR
$Self->{LogObject}->Log( Priority => 'info', Message => "$_ not in database, rejecting and sending email" );
# Send Agent an email to notify of blocked ticket - MichaelR
$Self->{EmailObject}->Send(
To => 'whoever-you-want@yourdomain.com',
From => 'postmaster-address@yourdomain.com',
Subject => "OTRS has blocked an unknown incoming ticket from: $GetParam{SenderEmailAddress}",
Body => "Hello <whoever>,\r\nOTRS recieved an email from $GetParam{SenderEmailAddress} attempting to log a task.\r\nOTRS doesn't know who this is and has NOT created a ticket.\r\nAttached is the body of their email.\r\nWe need to sort this out so it doesn't happen next time.",
Charset => $Self->{ConfigObject}->Get('DefaultCharset'),
MimeType => 'text/plain',
Loop => 1,
Attachment => [
{
Filename => 'customer-email.txt',
Content => "Subject: $Param{GetParam}->{Subject}\r\nBody: $Param{GetParam}->{Body}",
ContentType => 'application/octet-stream',
}
],
);
return;
}
That should be about it....
(I have submitted this to the OTRS Idea's thingo)
Cheers,
Michael
edit by crythias: removed color tag in code