Skip to content
Snippets Groups Projects
Commit 65444369 authored by Jared Hancock's avatar Jared Hancock
Browse files

fetch: Implement parsing attached email

If the content of the message is of type `message/rfc822`, then support
downloading the body of the message and sending it off to the mail parsing
system, simulating a piped email.
parent ffd04081
No related branches found
No related tags found
No related merge requests found
......@@ -141,9 +141,10 @@ class TicketApiController extends ApiController {
return $ticket;
}
function processEmail() {
function processEmail($data=false) {
$data = $this->getEmailRequest();
if (!$data)
$data = $this->getEmailRequest();
if (($thread = ThreadEntry::lookupByEmailHeaders($data))
&& $thread->postEmail($data)) {
......
......@@ -522,6 +522,18 @@ class MailFetcher {
// then this is a message with the forwarded message as the
// attachment. Download the body and pass it along to the mail
// parsing engine.
$info = Mail_Parse::splitHeaders($mailinfo['header']);
if (strtolower($info['Content-Type']) == 'message/rfc822') {
if ($wrapped = $this->getPart($mid, 'message/rfc822')) {
require_once INCLUDE_DIR.'api.tickets.php';
// Simulate piping the contents into the system
$api = new TicketApiController();
$parser = new EmailDataParser();
if ($data = $parser->parse($wrapped))
return $api->processEmail($data);
}
// If any of this fails, create the ticket as usual
}
//Is the email address banned?
if($mailinfo['email'] && TicketFilter::isBanned($mailinfo['email'])) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment