Initial email scrip work
This commit is contained in:
commit
0bf9242864
3
README.md
Normal file
3
README.md
Normal file
@ -0,0 +1,3 @@
|
||||
#About
|
||||
|
||||
This repository contains a collection of RT Scrips for various tasks, so that they can be used as a collection of recipies for future development
|
73
SendEmail.txt
Normal file
73
SendEmail.txt
Normal file
@ -0,0 +1,73 @@
|
||||
**** Custom condition:
|
||||
|
||||
return 0 unless $self->TicketObj->QueueObj->Name eq "test-queue";
|
||||
|
||||
# Check https://rt-wiki.bestpractical.com/wiki/CustomConditionSnippets - for solutions
|
||||
my $txn = $self->TransactionObj;
|
||||
my $type = $txn->Type;
|
||||
return 0 unless $type eq "Status"
|
||||
|| ( $type eq 'Set' && $txn->Field eq 'Status');
|
||||
return 0 unless $txn->OldValue eq "new";
|
||||
return 0 unless $txn->NewValue eq "open";
|
||||
|
||||
return 1;
|
||||
|
||||
|
||||
|
||||
**** Custom action preparation code:
|
||||
|
||||
require RT::Action::SendEmail;
|
||||
use strict;
|
||||
use vars qw/@ISA/;
|
||||
@ISA = qw(RT::Action::SendEmail);
|
||||
$self->SetRecipients();
|
||||
$self->SUPER::Prepare();
|
||||
$self->SUPER::Commit();
|
||||
|
||||
sub SetRecipients {
|
||||
my $self = shift;
|
||||
my $ticket = $self->TicketObj;
|
||||
my ( @To, @PseudoTo, @Cc, @Bcc );
|
||||
my $arg ='Owner,Requestor,AdminCc,Cc';
|
||||
##Requestor
|
||||
push @To, $ticket->Requestors->MemberEmailAddresses;
|
||||
|
||||
##FriendlyToLineFormat
|
||||
#if ( RT->Config->Get('UseFriendlyToLine') ) {
|
||||
# unless (@To) {
|
||||
# push @PseudoTo,
|
||||
# sprintf RT->Config->Get('FriendlyToLineFormat'), $arg, $ticket->id;
|
||||
# }
|
||||
#}
|
||||
|
||||
my $creator = $self->TransactionObj->CreatorObj->EmailAddress();
|
||||
#Strip the sender out of the To, Cc and AdminCc and set the
|
||||
# recipients fields used to build the message by the superclass.
|
||||
# unless a flag is set
|
||||
if (RT->Config->Get('NotifyActor')) {
|
||||
@{ $self->{'To'} } = @To;
|
||||
@{ $self->{'Cc'} } = @Cc;
|
||||
@{ $self->{'Bcc'} } = @Bcc;
|
||||
}
|
||||
else {
|
||||
@{ $self->{'To'} } = grep ( lc $_ ne lc $creator, @To );
|
||||
@{ $self->{'Cc'} } = grep ( lc $_ ne lc $creator, @Cc );
|
||||
@{ $self->{'Bcc'} } = grep ( lc $_ ne lc $creator, @Bcc );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
**** Custom action commit code: (Useful for diagnostics)
|
||||
|
||||
|
||||
my $ticket = $self->TicketObj;
|
||||
|
||||
if ($self->TicketObj->Status() ne "new") {
|
||||
return 1;
|
||||
}
|
||||
|
||||
$ticket->Comment(Content => 'Script #21 - sending email to requestor');
|
||||
$ticket->Comment(Content => 'Status is: '.$self->TicketObj->Status());
|
||||
return 1;
|
Loading…
x
Reference in New Issue
Block a user