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
fb8a4bf6
Commit
fb8a4bf6
authored
6 years ago
by
Peter Rotich
Browse files
Options
Downloads
Plain Diff
Merge remote branch 'upstream/develop' into develop-next
parents
d3b0a944
3299278d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
include/class.mailfetch.php
+45
-6
45 additions, 6 deletions
include/class.mailfetch.php
with
45 additions
and
6 deletions
include/class.mailfetch.php
+
45
−
6
View file @
fb8a4bf6
...
...
@@ -399,8 +399,17 @@ class MailFetcher {
return
$header
;
}
function
fetchBody
(
$mid
,
$index
,
$encoding
)
{
$body
=
imap_fetchbody
(
$this
->
mbox
,
$mid
,
$index
);
if
(
$body
&&
$encoding
)
$body
=
$this
->
decode
(
$body
,
$encoding
);
return
$body
;
}
//search for specific mime type parts....encoding is the desired encoding.
function
getPart
(
$mid
,
$mimeType
,
$encoding
=
false
,
$struct
=
null
,
$partNumber
=
false
,
$recurse
=-
1
,
$recurseIntoRfc822
=
true
)
{
function
getPart
(
$mid
,
$mimeType
,
$encoding
=
false
,
$struct
=
null
,
$partNumber
=
false
,
$recurse
=-
1
,
$recurseIntoRfc822
=
false
)
{
if
(
!
$struct
&&
$mid
)
$struct
=@
imap_fetchstructure
(
$this
->
mbox
,
$mid
);
...
...
@@ -490,8 +499,9 @@ class MailFetcher {
*/
function
getAttachments
(
$part
,
$index
=
0
)
{
if
(
$part
&&
!
$part
->
parts
)
{
$ctype
=
$part
?
$this
->
getMimeType
(
$part
)
:
false
;
if
(
$part
&&
(
!
$part
->
parts
||
strcasecmp
(
$ctype
,
'message/rfc822'
)
===
0
))
{
//Check if the part is an attachment.
$filename
=
false
;
if
(
$part
->
ifdisposition
&&
$part
->
ifdparameters
...
...
@@ -516,6 +526,12 @@ class MailFetcher {
$filename
=
_S
(
'image'
)
.
'-'
.
Misc
::
randCode
(
4
)
.
'.'
.
strtolower
(
$part
->
subtype
);
}
// Attached message/rfc822 without filename.
if
(
!
$filename
&&
$ctype
&&
strcasecmp
(
$ctype
,
'message/rfc822'
)
===
0
)
$filename
=
'email-message-'
.
Misc
::
randCode
(
4
)
.
'.eml'
;
if
(
$filename
)
{
return
array
(
array
(
...
...
@@ -673,11 +689,13 @@ class MailFetcher {
return
true
;
//Report success (moved or delete)
}
// P
arse MS TNEF email
s
// P
rocess overloaded attachment
s
if
((
$struct
=
imap_fetchstructure
(
$this
->
mbox
,
$mid
))
&&
(
$attachments
=
$this
->
getAttachments
(
$struct
)))
{
foreach
(
$attachments
as
$i
=>
$info
)
{
if
(
0
===
strcasecmp
(
'application/ms-tnef'
,
$info
[
'type'
]))
{
switch
(
strtolower
(
$info
[
'type'
]))
{
// Parse MS TNEF emails
case
'application/ms-tnef'
:
try
{
$data
=
$this
->
decode
(
imap_fetchbody
(
$this
->
mbox
,
$mid
,
$info
[
'index'
]),
$info
[
'encoding'
]);
...
...
@@ -690,6 +708,26 @@ class MailFetcher {
}
catch
(
TnefException
$ex
)
{
// Noop -- winmail.dat remains an attachment
}
break
;
// Parse attached email message
case
'message/rfc822'
:
try
{
// Fetch the header of attached mime message.
$body
=
$this
->
fetchBody
(
$mid
,
$info
[
'index'
]
.
'.0'
,
$info
[
'encoding'
]);
// Add fake body to make the parser happy
if
(
$body
)
$body
.
=
"
\n\n
Junk"
;
$parser
=
new
Mail_Parse
(
$body
);
if
(
$parser
->
decode
()
&&
(
$subj
=
$parser
->
getSubject
()))
$attachments
[
$i
][
'name'
]
=
$subj
.
'.eml'
;
}
catch
(
Exception
$ex
)
{
// Noop -- use random name
}
$body
=
$parser
=
null
;
break
;
}
}
}
...
...
@@ -948,7 +986,8 @@ class MailFetcher {
db_query
(
'UPDATE '
.
EMAIL_TABLE
.
' SET mail_errors=mail_errors+1, mail_lasterror=NOW() WHERE email_id='
.
db_input
(
$emailId
));
if
(
++
$errors
>=
$MAXERRORS
)
{
//We've reached the MAX consecutive errors...will attempt logins at delayed intervals
$msg
=
"
\n
"
.
_S
(
'osTicket is having trouble fetching emails from the following mail account'
)
.
":
\n
"
.
// XXX: Translate me
$msg
=
"
\n
osTicket is having trouble fetching emails from the following mail account:
\n
"
.
"
\n
"
.
_S
(
'User'
)
.
": "
.
$fetcher
->
getUsername
()
.
"
\n
"
.
_S
(
'Host'
)
.
": "
.
$fetcher
->
getHost
()
.
"
\n
"
.
_S
(
'Error'
)
.
": "
.
$fetcher
->
getLastError
()
.
...
...
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