Sample code for 30+ languages & platforms
PHP ActiveX Requires Chilkat v11.0.0+

Pass an Email object to the MIME API

See more Email Object Examples

Serialize an Email into a fresh BinData buffer and load those bytes into Mime to inspect the tree. Keep the original file separately when byte-for-byte preservation matters, such as for DKIM verification.

Chilkat PHP ActiveX Downloads

PHP ActiveX
<?php

$success = 0;

//  Assumes Chilkat is unlocked. See Global Unlock Sample.

$email = new COM("Chilkat.Email");
$success = $email->LoadEml('message.eml');
if ($success != 1) {
    print $email->LastErrorText . "\n";
    exit;
}

$mimeBytes = new COM("Chilkat.BinData");
$success = $email->GetMimeBd($mimeBytes);
if ($success != 1) {
    print $email->LastErrorText . "\n";
    exit;
}

$mime = new COM("Chilkat.Mime");
$success = $mime->LoadMimeBd($mimeBytes);
if ($success != 1) {
    print $mime->LastErrorText . "\n";
    exit;
}

print $mime->getStructure('text') . "\n";

?>