<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/usr/bin/perl
#######################################################################
#    automail.pl
#
#    Perl script used for remote email piping...same as as the PHP version.
#
#    Peter Rotich &lt;peter@osticket.com&gt;
#    Copyright (c) 2006-2013 osTicket
#    http://www.osticket.com
#
#    Released under the GNU General Public License WITHOUT ANY WARRANTY.
#    See LICENSE.TXT for details.
#
#    vim: expandtab sw=4 ts=4 sts=4:
#######################################################################

#Configuration: Enter the url and key. That is it.
#  url=&gt; URL to pipe.php e.g http://yourdomain.com/support/api/tickets.email
#  key=&gt; API Key (see admin panel on how to generate a key)

%config = (url =&gt; 'http://yourdomain.com/support/api/tickets.email',
           key =&gt; 'API KEY HERE');

#Get piped message from stdin
while (&lt;STDIN&gt;) {
    $rawemail .= $_;
}

use LWP::UserAgent;
$ua = LWP::UserAgent-&gt;new;

$ua-&gt;agent('osTicket API Client v1.7');
$ua-&gt;default_header('X-API-Key' =&gt; $config{'key'});
$ua-&gt;timeout(10);

use HTTP::Request::Common qw(POST);

my $enc ='text/plain';
my $req = (POST $config{'url'}, Content_Type =&gt; $enc, Content =&gt; $rawemail);
$response = $ua-&gt;request($req);

#
# Process response
# Add exit codes - depending on what your  MTA expects.
# By default postfix exit codes are used - which are standard for MTAs.
#
    
use Switch;

$code = 75;    
switch($response-&gt;code) {
    case 201 { $code = 0; }
    case 400 { $code = 66; }
    case [401,403] { $code = 77; }
    case [415,416,417,501] { $code = 65; }
    case 503 { $code = 69 }
    case 500 { $code = 75 }
}
#print "RESPONSE: ". $response-&gt;code. "&gt;&gt;&gt;".$code;
exit $code;
</pre></body></html>