OTRS::ForwardQueue - Forwards the contents of an OTRS queue to a given email address.


version 0.13


    use OTRS::ForwardQueue;

    %query = (
      Queues => ['MyQueue'],
      States => ['new', 'open'],
      Locks => ['unlock'],
      UserID => 1,

    %options = (
      ForwardTo => '',
      TempDir => '/tmp',
      HistoryComment => 'Forward to other request system',
      SMTP => 1,
      SMTPServer => '',
      NotifyCustomer => 1,
      NotifyCustomerTemplate => '',
      TemplatesPath => '/usr/local/templates',
      Debug => 1,

    my $fq = OTRS::ForwardQueue->new('query' => \%query, 'options' => \%options);



This module queries the Open Technology Real Services (OTRS) ticket management system for tickets matching the query provided and then forwards these tickets to an email address, closing them in OTRS.

The following functions are provided:

new(\%query, \%options)

Produced automatically by Moose, this is the constructor for the class.


Reference to a hash which contains the query parameters. This takes the same key/value pairs as the TicketSearch function of Kernel::System::TicketSearch, except that the Result value is always set to 'ARRAY'.


Required list of options which affect how the queue is processed.

HistoryComment (required): The comment left in the history of the ticket when it is forwarded to anther system.
TempDir (optional): Override the temporary directory used by the OTRS cache. Probably needs to be set if you are not running the module as the web server user (e.g. apache). If you get errors about file permissions, try setting this to '/tmp'.
ForwardTo (required): The email address to forward tickets to.
DisableLocking (optional): Set to 1 to disable locking of forwarded tickets. Default behaviour is to lock tickets.
DisableHistory (optional): Set to 1 to disable leaving a comment in the history (effectively makes HistoryComment redundant). Default behaviour is to add a comment.
DisableClosing (optional): Set to 1 to disable closing the ticket after forwarding. Default behaviour is to mark ticket as 'closed successful'.
DisableEmail (optional): Set to 1 to disable sending any emails, which effectively prevents forwarding of tickets. Default behaviour is to send email. Included as an option to allow module users to test their code before sending out emails.
SMTP (optional): Set to 1 to use an SMTP server to send email, instead of the local MTA.
SMTPServer (optional): Host name or IP address of the SMTP server to use. Only effective if SMTP is set to 1.
NotifyCustomer (optional): Set to 1 to create a new article on the ticket and notify the customer that it has been forwarded.
NotifyCustomerTemplate (optional): Relative filename to template for customer notification. Required if NotifyCustomer is set to 1.
TemplatesPath (optional): Absolute path to template directory. Required if NotifyCustomerTemplate is set.
Debug (optional): Set to 1 to print extra debugging information, such as the IDs of forwarded tickets.

Processes the queue based on the options passed in the constructor.


Perl version 5.14 or higher is required. You may be able to use the module with older versions of Perl, but this is neither tested nor supported.

This module requires the following modules:

Although some of the above modules are used for optional features, all the dependencies must be installed as this module will attempt to import all of them.

You must also have the OTRS source installed and available via @INC. This module has been tested with OTRS 3.2.10 and 3.3.9.


Running a script which uses this module as a cron job may require some additional tweaks. The easiest way is to create a small wrapper script to set the various library paths correctly, such as the one below:

    # Set this to the absolute path to your OTRS install, so those
    # modules can be loaded
    # Comment out this line if you are not using local::lib
    # Change this to the path of your script
    /usr/bin/perl "$FQ_OTRS_LIB" "$FQ_LOCAL_LIB" /path/to/


None reported.


No bugs have been reported.

Please report any bugs through the Github issue system:


Paul Waring <>


This software is Copyright (c) 2014 by University of Manchester.

This is free software, licensed under:

  The GNU Affero General Public License, Version 3, November 2007