Im currently working on a PHP + POP3 email webbased email service.
I have coded almost all of the site but my headers are messing up.
The $email variable is a array it includes all the headers and message.
Is the code I have to split the headers and the message.
So all the following work fine such as..
$email['headers']['From'] = the message sender
$email['headers']['Envelope-to'] = whos the message is for
$email['headers']['Date'] = date email sent
$email['headers']['Subject'] = subject
But when it comes to the message it works fine with my own send email script and orange email. But with hotmail and gmail the message is messed up with some headers in it.
$email['message'] = the code for the message
With Gmail i get this
And hotmail I almost get the same message.
I hope you can help me with my problem..
Daniel
I have coded almost all of the site but my headers are messing up.
| Code: |
| $email = parse_email($email); |
The $email variable is a array it includes all the headers and message.
| Code: |
| 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]; } $message = implode('', $message); // Return array $email = array(); $email['message'] = $message; $email['headers'] = $headers; return $email; } |
Is the code I have to split the headers and the message.
So all the following work fine such as..
$email['headers']['From'] = the message sender
$email['headers']['Envelope-to'] = whos the message is for
$email['headers']['Date'] = date email sent
$email['headers']['Subject'] = subject
But when it comes to the message it works fine with my own send email script and orange email. But with hotmail and gmail the message is messed up with some headers in it.
$email['message'] = the code for the message
With Gmail i get this
| Code: |
| ------=_Part_177979_24935233.1188244633529
Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline ***Orig message i sent, how it should be*** ------=_Part_177979_24935233.1188244633529 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline ***Orig message i sent, how it should be*** ** Repeated ** ------=_Part_177979_24935233.1188244633529-- |
And hotmail I almost get the same message.
I hope you can help me with my problem..
Daniel
