jpratt Posted July 30, 2008 Share Posted July 30, 2008 I am using the pop3 class found at: http://www.phpclasses.org/browse/package/1120.html. Everything is working but I want to format the email to get rid of all the header information, and if possible all the replied emails below the main content. So if an email is a reply it does not contain the original email below it. Any ideas? Link to comment https://forums.phpfreaks.com/topic/117353-recieving-email/ Share on other sites More sharing options...
jpratt Posted July 30, 2008 Author Share Posted July 30, 2008 Im using the following but it still includes some header information and does not remove the email below the message. function parse_email ($email) { // Split header and message $header = array(); $message = array(); $is_header = true; foreach ($email as $line) { if ($line == '<HEADER> ' . "\r\n") continue; if ($line == '<MESSAGE> ' . "\r\n") continue; if ($line == '</MESSAGE> ' . "\r\n") continue; if ($line == '</HEADER> ' . "\r\n") { $is_header = false; continue; } if ($is_header == true) { $header[] = $line; } else { $message[] = $line; } } // Parse headers $headers = array(); foreach ($header as $line) { $colon_pos = strpos($line, ':'); $space_pos = strpos($line, ' '); if ($colon_pos === false OR $space_pos < $colon_pos) { // attach to previous $previous .= "\r\n" . $line; continue; } // Get key $key = substr($line, 0, $colon_pos); // Get value $value = substr($line, $colon_pos+2); $headers[$key] = $value; $previous =& $headers[$key]; } // Parse message $message = implode('', $message); // Return array $email = array(); $email['message'] = $message; $email['headers'] = $headers; return $email; } Anyone done this before and have a way of doing this? Link to comment https://forums.phpfreaks.com/topic/117353-recieving-email/#findComment-603805 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.