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
7dbf9628
Commit
7dbf9628
authored
12 years ago
by
Peter Rotich
Browse files
Options
Downloads
Plain Diff
Merge pull request #387 from protich/issue/340
Auto-detect bounced emails
parents
e123b97e
d153d16c
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
api/pipe.php
+10
-2
10 additions, 2 deletions
api/pipe.php
include/class.filter.php
+51
-12
51 additions, 12 deletions
include/class.filter.php
include/class.mailfetch.php
+7
-1
7 additions, 1 deletion
include/class.mailfetch.php
with
68 additions
and
15 deletions
api/pipe.php
+
10
−
2
View file @
7dbf9628
...
@@ -106,10 +106,18 @@ if($ticket) {
...
@@ -106,10 +106,18 @@ if($ticket) {
}
elseif
((
$ticket
=
Ticket
::
create
(
$var
,
$errors
,
'email'
)))
{
// create new ticket.
}
elseif
((
$ticket
=
Ticket
::
create
(
$var
,
$errors
,
'email'
)))
{
// create new ticket.
$msgid
=
$ticket
->
getLastMsgId
();
$msgid
=
$ticket
->
getLastMsgId
();
}
else
{
// failure....
}
else
{
// failure....
// report success on hard rejection
if
(
isset
(
$errors
[
'errno'
])
&&
$errors
[
'errno'
]
==
403
)
if
(
isset
(
$errors
[
'errno'
])
&&
$errors
[
'errno'
]
==
403
)
api_exit
(
EX_SUCCESS
);
//report success on hard rejection
api_exit
(
EX_SUCCESS
);
api_exit
(
EX_DATAERR
,
'Ticket create Failed '
.
implode
(
"
\n
"
,
$errors
)
.
"
\n\n
"
);
// check if it's a bounce!
if
(
$var
[
'header'
]
&&
TicketFilter
::
isAutoBounce
(
$var
[
'header'
]))
{
$ost
->
logWarning
(
'Bounced email'
,
$var
[
'message'
],
false
);
api_exit
(
EX_SUCCESS
);
}
api_exit
(
EX_DATAERR
,
'Ticket create Failed '
.
implode
(
"
\n
"
,
$errors
)
.
"
\n\n
"
);
}
}
//Ticket created...save attachments if enabled.
//Ticket created...save attachments if enabled.
...
...
This diff is collapsed.
Click to expand it.
include/class.filter.php
+
51
−
12
View file @
7dbf9628
...
@@ -866,6 +866,10 @@ class TicketFilter {
...
@@ -866,6 +866,10 @@ class TicketFilter {
* http://msdn.microsoft.com/en-us/library/ee219609(v=exchg.80).aspx
* http://msdn.microsoft.com/en-us/library/ee219609(v=exchg.80).aspx
*/
*/
/* static */
function
isAutoResponse
(
$headers
)
{
/* static */
function
isAutoResponse
(
$headers
)
{
if
(
$headers
&&
!
is_array
(
$headers
))
$headers
=
Mail_Parse
::
splitHeaders
(
$headers
);
$auto_headers
=
array
(
$auto_headers
=
array
(
'Auto-Submitted'
=>
'AUTO-REPLIED'
,
'Auto-Submitted'
=>
'AUTO-REPLIED'
,
'Precedence'
=>
array
(
'AUTO_REPLY'
,
'BULK'
,
'JUNK'
,
'LIST'
),
'Precedence'
=>
array
(
'AUTO_REPLY'
,
'BULK'
,
'JUNK'
,
'LIST'
),
...
@@ -875,21 +879,56 @@ class TicketFilter {
...
@@ -875,21 +879,56 @@ class TicketFilter {
'X-Autoresponse'
=>
''
,
'X-Autoresponse'
=>
''
,
'X-Auto-Reply-From'
=>
''
'X-Auto-Reply-From'
=>
''
);
);
foreach
(
$auto_headers
as
$header
=>
$find
)
{
foreach
(
$auto_headers
as
$header
=>
$find
)
{
if
(
$value
=
strtoupper
(
$headers
[
$header
]))
{
if
(
!
isset
(
$headers
[
$header
]))
continue
;
# Search text must be found at the beginning of the header
# value. This is especially import for something like the
$value
=
strtoupper
(
$headers
[
$header
]);
# subject line, where something like an autoreponse may
# Search text must be found at the beginning of the header
# appear somewhere else in the value.
# value. This is especially import for something like the
if
(
is_array
(
$find
))
{
# subject line, where something like an autoreponse may
foreach
(
$find
as
$f
)
# appear somewhere else in the value.
if
(
strpos
(
$value
,
$f
)
===
0
)
return
true
;
if
(
is_array
(
$find
))
{
}
elseif
(
strpos
(
$value
,
$find
)
===
0
)
{
foreach
(
$find
as
$f
)
return
true
;
if
(
strpos
(
$value
,
$f
)
===
0
)
}
return
true
;
}
elseif
(
strpos
(
$value
,
$find
)
===
0
)
{
return
true
;
}
}
}
}
# Bounces also counts as auto-responses.
if
(
self
::
isAutoBounce
(
$headers
))
return
true
;
return
false
;
}
function
isAutoBounce
(
$headers
)
{
if
(
$headers
&&
!
is_array
(
$headers
))
$headers
=
Mail_Parse
::
splitHeaders
(
$headers
);
$bounce_headers
=
array
(
'From'
=>
array
(
'<MAILER-DAEMON@MAILER-DAEMON>'
,
'MAILER-DAEMON'
,
'<>'
),
'Subject'
=>
array
(
'DELIVERY FAILURE'
,
'DELIVERY STATUS'
,
'UNDELIVERABLE:'
),
);
foreach
(
$bounce_headers
as
$header
=>
$find
)
{
if
(
!
isset
(
$headers
[
$header
]))
continue
;
$value
=
strtoupper
(
$headers
[
$header
]);
if
(
is_array
(
$find
))
{
foreach
(
$find
as
$f
)
if
(
strpos
(
$value
,
$f
)
===
0
)
return
true
;
}
elseif
(
strpos
(
$value
,
$find
)
===
0
)
{
return
true
;
}
}
return
false
;
return
false
;
}
}
...
...
This diff is collapsed.
Click to expand it.
include/class.mailfetch.php
+
7
−
1
View file @
7dbf9628
...
@@ -378,7 +378,7 @@ class MailFetcher {
...
@@ -378,7 +378,7 @@ class MailFetcher {
//Is the email address banned?
//Is the email address banned?
if
(
$mailinfo
[
'email'
]
&&
TicketFilter
::
isBanned
(
$mailinfo
[
'email'
]))
{
if
(
$mailinfo
[
'email'
]
&&
TicketFilter
::
isBanned
(
$mailinfo
[
'email'
]))
{
//We need to let admin know...
//We need to let admin know...
$ost
->
logWarning
(
'Ticket denied'
,
'Banned email - '
.
$mailinfo
[
'email'
]);
$ost
->
logWarning
(
'Ticket denied'
,
'Banned email - '
.
$mailinfo
[
'email'
]
,
false
);
return
true
;
//Report success (moved or delete)
return
true
;
//Report success (moved or delete)
}
}
...
@@ -421,6 +421,12 @@ class MailFetcher {
...
@@ -421,6 +421,12 @@ class MailFetcher {
if
(
isset
(
$errors
[
'errno'
])
&&
$errors
[
'errno'
]
==
403
)
if
(
isset
(
$errors
[
'errno'
])
&&
$errors
[
'errno'
]
==
403
)
return
true
;
return
true
;
# check if it's a bounce!
if
(
$var
[
'header'
]
&&
TicketFilter
::
isAutoBounce
(
$var
[
'header'
]))
{
$ost
->
logWarning
(
'Bounced email'
,
$var
[
'message'
],
false
);
return
true
;
}
//TODO: Log error..
//TODO: Log error..
return
null
;
return
null
;
}
}
...
...
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