An osTicket plugin to rewrite incoming emails
Switch branches/tags
Nothing to show
Clone or download
Latest commit 2c5e3ba Jul 5, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE Initial May 20, 2016 Updating delete attachments info Sep 27, 2017
class.RewriterPlugin.php Relates to #6, needs testing Jul 5, 2018
config.php Relates to #6, needs testing Jul 5, 2018
plugin.php Actually getting tests done this time Jul 20, 2017

osTicket - Ticket Rewriter Plugin

Enables rewriting of email messages before a new ticket is created.

To install

  • Download master zip and extract into /include/plugins/rewriter
  • Then Install and enable as per normal osTicket Plugins

To configure

Visit the Admin-panel, select Manage => Plugins, choose the Ticket Rewriter plugin


  • Only works on Emails!
  • Assumes English.. Sorry, I don't speak enough of even one foreign language to write regex for them. Let me know if you've any ideas!
  • If you require user login, it won't rewrite a ticket to a non-existent user. Only tested with Registration disabled!
  • Assumes osTicket v1.10+ The API changes a bit between versions..

Admin Options

Email Forwarding rewriter configuration:

Ensures that the original sender of a message is preserved in the ticket metadata, and allows replies to go back to them.

  • Admin options allow you to specify which domains are allowed to be rewritten (ie, enter your company domain).
  • Admin option to parse/rewrite messages from Drupal Contact forms
  • Admin option to enable logging of actions into the osTicket admin logs

I suggest at least your "domain name", otherwise the forwarding detector will ignore all forwarded mail.

To start, you should probably enable logging. You can disable when you're done testing. (While code is prerelease, DEBUG has been left on, so you can see many log entries in your webserver logs, simply change that to FALSE in class.RewriterPlugin.php to stop them).

Delete Attachments:

  • A single checkbox that removes all attachments for inbound emails.
  • A textbox to enter "Department" names, or id's. Enter one here, and any attachments emailed to that department get's purged. Note, ATTACHMENTS.. still allows inline images, but all files are purged. If you want to purge everything, you can turn it off, or use the admin console to specify what files are attachable, or, simply check the box that removes all of them.

Drupal Contact Parser

If you use Drupal on any external websites, and don't use an API to talk to osTickets (ie, the Contact form simply emails your ticket system), you can use the Drupal Contact Parser to rewrite those inbound emails back into the original senders, so tickets are as if they were created by the original sender.

Extra Power Admin Settings

Some dangerous settings have been added, allowing the admin to define find & replace patterns in both subjects, emails and message bodies for incoming emails. The regex is particularly flexible.. includes $1 backref's for matched groups etc.

Some interesting use-cases would be good, if you've found a use for it, submit a pull request for the readme to add them here:

Email Replacements (case insensitive, applies to email address itself)

Text Replacements (case insensitive, applies to subject and body only)

  • the customer is always right:I don't care
  • cheque is in the mail:I'm a tool
  • failure:Success (make complaint tickets entertaining: "I am not happy with this product's absolute Success!"

Regex Text Replacements (validated raw php regex, applies to everything we can, including mail headers)

  • /cloud/i:magic
  • /([\w\d]+).internal.lan/i:$1