Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function caughtEmail($full_email)
- {
- global $database;
- global $member;
- global $EmailClass;
- # Include email parser
- require_once('rfc822_addresses.class.php');
- require_once('mime_parser.class.php');
- # Create the email parser class
- $mime = new mime_parser_class;
- $mime->ignore_syntax_errors = 1;
- $parameters=array(
- 'Data'=>$full_email,
- );
- $mime->Decode($parameters, $decoded);
- for($message = 0; $message < count($decoded); $message++)
- {
- $mime->Analyze($decoded[$message], $results);
- if($mime->decode_bodies)
- {
- $mime->Analyze($decoded[$message], $results);
- }
- }
- # Get the name and email of the sender
- $fromName = $results['From'][0]['name'];
- $fromEmail = $results['From'][0]['address'];
- # If there is no fromName then fromName becomes fromEmail
- if(!isset($fromName) || empty($fromName))
- {
- $fromName1 = explode('@', $fromEmail);
- $fromName = $fromName1[0];
- }
- # Get the name and email of the recipient
- $toName = $results['To'][0]['name'];
- $toEmail = $results['To'][0]['address'];
- if(!isset($toName)) $toName = "";
- # Get the subject
- $subject = $results['Subject'];
- # Stop script is it's spam
- if(strpos($subject, '***SPAM***' !== FALSE))
- {
- exit;
- }
- # If no subject then make it (No Subject)
- if($subject=="") $subject = "(No Subject)";
- # Retrieve Email ID from the subject
- preg_match('/\[#(\d+)\]/U', $subject, $subject_ticket_id);
- # Get the body
- $body = $results['Alternative'][0]['Data'];
- # Retrive the Email ID from the body
- preg_match('/Email ID: (?P<body_ticket_id>\w+)/', $body, $body_ticket_id);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement