Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
osticket
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
docker
osticket
Commits
382a12d1
Commit
382a12d1
authored
12 years ago
by
Peter Rotich
Browse files
Options
Downloads
Patches
Plain Diff
Add remote piping scripts
parent
6fcd880b
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
setup/scripts/automail.php
+80
-0
80 additions, 0 deletions
setup/scripts/automail.php
setup/scripts/automail.pl
+60
-0
60 additions, 0 deletions
setup/scripts/automail.pl
with
140 additions
and
0 deletions
setup/scripts/automail.php
0 → 100755
+
80
−
0
View file @
382a12d1
#!/usr/bin/php -q
<?php
/*********************************************************************
automail.php
PHP script used for remote email piping...same as as the perl version.
Peter Rotich <peter@osticket.com>
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 => URL to api/tickets.email e.g http://yourdomain.com/support/api/tickets.email
# key => API's Key (see admin panel on how to generate a key)
#
$config
=
array
(
'url'
=>
'http://yourdomain.com/support/api/tickets.email'
,
'key'
=>
'API KEY HERE'
);
#pre-checks
function_exists
(
'file_get_contents'
)
or
die
(
'upgrade php >=4.3'
);
function_exists
(
'curl_version'
)
or
die
(
'CURL support required'
);
#read stdin (piped email)
$data
=
file_get_contents
(
'php://stdin'
)
or
die
(
'Error reading stdin. No message'
);
#set timeout
set_time_limit
(
10
);
#curl post
$ch
=
curl_init
();
curl_setopt
(
$ch
,
CURLOPT_URL
,
$config
[
'url'
]);
curl_setopt
(
$ch
,
CURLOPT_POST
,
1
);
curl_setopt
(
$ch
,
CURLOPT_POSTFIELDS
,
$data
);
curl_setopt
(
$ch
,
CURLOPT_USERAGENT
,
'osTicket API Client v1.7'
);
curl_setopt
(
$ch
,
CURLOPT_HEADER
,
TRUE
);
curl_setopt
(
$ch
,
CURLOPT_HTTPHEADER
,
array
(
'Expect:'
,
'X-API-Key: '
.
$config
[
'key'
]));
curl_setopt
(
$ch
,
CURLOPT_FOLLOWLOCATION
,
FALSE
);
curl_setopt
(
$ch
,
CURLOPT_RETURNTRANSFER
,
TRUE
);
$result
=
curl_exec
(
$ch
);
curl_close
(
$ch
);
//Use postfix exit codes...expected by MTA.
$code
=
75
;
if
(
preg_match
(
'/HTTP\/.* ([0-9]+) .*/'
,
$result
,
$status
))
{
switch
(
$status
[
1
])
{
case
201
:
//Success
$code
=
0
;
break
;
case
400
:
$code
=
66
;
break
;
case
401
:
/* permission denied */
case
403
:
$code
=
77
;
break
;
case
415
:
case
416
:
case
417
:
case
501
:
$code
=
65
;
break
;
case
503
:
$code
=
69
;
break
;
case
500
:
//Server error.
default
:
//Temp (unknown) failure - retry
$code
=
75
;
}
}
exit
(
$code
);
?>
This diff is collapsed.
Click to expand it.
setup/scripts/automail.pl
0 → 100755
+
60
−
0
View file @
382a12d1
#!/usr/bin/perl
#######################################################################
# automail.pl
#
# Perl script used for remote email piping...same as as the PHP version.
#
# Peter Rotich <peter@osticket.com>
# 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=> URL to pipe.php e.g http://yourdomain.com/support/api/tickets.email
# key=> API Key (see admin panel on how to generate a key)
%config
=
(
url
=>
'
http://yourdomain.com/support/api/tickets.email
',
key
=>
'
API KEY HERE
');
#Get piped message from stdin
while
(
<
STDIN
>
)
{
$rawemail
.=
$_
;
}
use
LWP::
UserAgent
;
$ua
=
LWP::
UserAgent
->
new
;
$ua
->
agent
('
osTicket API Client v1.7
');
$ua
->
default_header
('
X-API-Key
'
=>
$config
{'
key
'});
$ua
->
timeout
(
10
);
use
HTTP::Request::
Common
qw(POST)
;
my
$enc
=
'
text/plain
';
my
$req
=
(
POST
$config
{'
url
'},
Content_Type
=>
$enc
,
Content
=>
$rawemail
);
$response
=
$ua
->
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
->
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->code. ">>>".$code;
exit
$code
;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment