You are not logged in.
I've tweaked my MailCollector.php file to remove the automatically added outlook header if users don't delete it when replying by email. The only downside I can see to the way I did it is that if a user's response naturally includes "From:" it will not include from that point forward any part of their message in the ticket. I left in the old delimiter as well and am checking the string length if both the original delimiter and the response header exist to get the shorter string (i.e. the one without the response header). Has anyone else done something similar? Any thoughts on how it could be improved? Any other pitfalls I might be missing? Thanks, Wickeret
$header_tag = NotificationTargetTicket::HEADERTAG;
$header_pattern = $header_tag . '.*' . $header_tag;
$header_pattern2 = 'From:' . '.*' . 'Sent:' . '.*' . 'To:' . '.*' . 'Subject:';
$footer_tag = NotificationTargetTicket::FOOTERTAG;
$footer_pattern = $footer_tag . '.*' . $footer_tag;
$has_header_line = preg_match('/' . $header_pattern . '/s', $tkt['content']);
$has_header_line2 = preg_match('/' . $header_pattern2 . '/s', $tkt['content']);
$has_footer_line = preg_match('/' . $footer_pattern . '/s', $tkt['content']);
if ($has_header_line && $has_header_line2 && $has_footer_line) {
// Strip all contents between header and footer line
$holder = preg_replace(
'/' . $header_pattern . '.*' . $footer_pattern . '/s',
'',
$tkt['content']
);
$holderlength = strlen($holder);
$holder2 = preg_replace(
'/' . $header_pattern2 . '.*' . $footer_pattern . '/s',
'',
$tkt['content']
);
$holderlength2 = strlen($holder2);
If ($holderlength2 < $holderlength) {
$tkt['content'] = $holder2;
} else {
$tkt['content'] = $holder;
}
} else if ($has_header_line && $has_footer_line) {
// Strip all contents between header and footer line
$tkt['content'] = preg_replace(
'/' . $header_pattern . '.*' . $footer_pattern . '/s',
'',
$tkt['content']
);
} else if ($has_header_line2 && $has_footer_line) {
// Strip all contents between header and footer line
$tkt['content'] = preg_replace(
'/' . $header_pattern2 . '.*' . $footer_pattern . '/s',
'',
$tkt['content']
);
} else if ($has_header_line) {
// Strip all contents between header line and end of message
$tkt['content'] = preg_replace(
'/' . $header_pattern . '.*$/s',
'',
$tkt['content']
);
} else if ($has_header_line2) {
// Strip all contents between header line and end of message
$tkt['content'] = preg_replace(
'/' . $header_pattern2 . '.*$/s',
'',
$tkt['content']
);
} else if ($has_footer_line) {
// Strip all contents between begin of message and footer line
$tkt['content'] = preg_replace(
'/^.*' . $footer_pattern . '/s',
'',
$tkt['content']
);
}
Offline
I also wanted to do the same because notifications with that text don't look good at all. Maybe a ticket assignment rule is the best way but I don't know if that's possible!
Offline