SendEmailAction: Difference between revisions
m (5 revisions imported) |
No edit summary |
||
Line 7: | Line 7: | ||
Create the following file, named [[SendEmailAction]].install: | Create the following file, named [[SendEmailAction]].install: | ||
<pre> | |||
# Used to install a scrip action. | |||
# | # | ||
# To install, | # To install, | ||
Line 20: | Line 21: | ||
Argument => '' }, | Argument => '' }, | ||
); | ); | ||
</pre> | |||
As the comments in the file indicate, you "install" this file using the '''rt-setup-database''' utility. | |||
<pre> | |||
rt-setup-database --action insert --datafile SendEmailAction.install | |||
</pre> | |||
Now when you create a scrip, you should have a new action available to you. To use it, first create a template which determines the content of the message you are sending, as well as the person or persons that will be getting this message. | Now when you create a scrip, you should have a new action available to you. To use it, first create a template which determines the content of the message you are sending, as well as the person or persons that will be getting this message. | ||
Line 31: | Line 33: | ||
Here is an example of a template you could use: | Here is an example of a template you could use: | ||
<pre> | |||
Bcc: user3@example.org | To: user1@example.org, user2@example.org | ||
Subject: {$Ticket->Subject} | Bcc: user3@example.org | ||
Subject: {$Ticket->Subject} | |||
A ticket has been created in this queue. | A ticket has been created in this queue. | ||
Line 43: | Line 46: | ||
{$Transaction->Content()} | {$Transaction->Content()} | ||
</pre> | |||
Now, create a scrip. Set the condition to "on create", the action to "send email", and specify your newly created template. | Now, create a scrip. Set the condition to "on create", the action to "send email", and specify your newly created template. | ||
Line 51: | Line 54: | ||
To use this action to send email to the members of an RT Group, use a template like this: | To use this action to send email to the members of an RT Group, use a template like this: | ||
<pre> | |||
To: { my $GroupObj = RT::Group->new($RT::SystemUser); | |||
$GroupObj->LoadUserDefinedGroup('Group Name'); | $GroupObj->LoadUserDefinedGroup('Group Name'); | ||
$GroupObj->MemberEmailAddressesAsString()} | $GroupObj->MemberEmailAddressesAsString()} | ||
Subject: {$Ticket->Subject} | Subject: {$Ticket->Subject} | ||
Line 64: | Line 68: | ||
{$Transaction->Content()} | {$Transaction->Content()} | ||
</pre> | |||
== Small problem with v3.8.4 and empty ticket body == | == Small problem with v3.8.4 and empty ticket body == |
Latest revision as of 12:08, 19 July 2016
The following is built into 3.8.X
This action handles the case where you want to send an email to a certain person, but not require that person to be on the ticket. E.g. whenever a ticket is created, you want to send an email to a certain group of people, but not add that group to the ticket.
This action does not require any Perl code, just a database edit. It uses code already in RT.
Create the following file, named SendEmailAction.install:
# Used to install a scrip action. # # To install, # execute # /path/to/rt3/sbin/rt-setup-database --action insert \ # --datafile /path/to/SendEmailAction.install # @ScripActions = ( { Name => 'Send Email', Description => 'Sends a message to those specified in the template', ExecModule => 'SendEmail', Argument => '' }, );
As the comments in the file indicate, you "install" this file using the rt-setup-database utility.
rt-setup-database --action insert --datafile SendEmailAction.install
Now when you create a scrip, you should have a new action available to you. To use it, first create a template which determines the content of the message you are sending, as well as the person or persons that will be getting this message.
Here is an example of a template you could use:
To: user1@example.org, user2@example.org Bcc: user3@example.org Subject: {$Ticket->Subject} A ticket has been created in this queue. {$RT::WebURL}Ticket/Display.html?id={$Ticket->id} ------------- {$Transaction->Content()}
Now, create a scrip. Set the condition to "on create", the action to "send email", and specify your newly created template.
If your scrip was queue-specific, you may also want to create a scrip handling tickets getting assigned to the queue.
To use this action to send email to the members of an RT Group, use a template like this:
To: { my $GroupObj = RT::Group->new($RT::SystemUser); $GroupObj->LoadUserDefinedGroup('Group Name'); $GroupObj->MemberEmailAddressesAsString()} Subject: {$Ticket->Subject} A ticket has been created in this queue. {$RT::WebURL}Ticket/Display.html?id={$Ticket->id} ------------- {$Transaction->Content()}
Small problem with v3.8.4 and empty ticket body
SendEmail fails with Request Tracker v3.8.4 if the body of the request is empty. For example if using the rt shell to create a ticket (useful for testing) like so:
rt create -t ticket set subject='TEST - please ignore' queue='Testing' requestor='address@thing.com'
Then the ticket has no content and there is an error message (Ubuntu Karmic puts this is in /var/log/syslog) like:
RT: error: unexpected end of header (/usr/share/request-tracker3.8/lib/RT/Template_Overlay.pm:356)