PHP Requires Chilkat v11.0.0+
PHP
Read an attached email
See more Email Object Examples
Open forward-as-attachment.eml from the forwarding example. Read the cover note’s subject, then open each attached message and inspect its own headers and attachment count. This works even when the outer message has no ordinary files.
Chilkat PHP Downloads
<?php
use Chilkat2\Email;
// Assumes Chilkat is unlocked. See Global Unlock Sample.
$wrapper = new Email();
try {
$wrapper->LoadEml('forward-as-attachment.eml');
} catch (\Chilkat2\Exception $e) {
echo $e->getMessage(), "\n";
exit;
}
echo 'Cover note: ', $wrapper->Subject, "\n";
if ($wrapper->NumAttachedMessages == 0) {
echo "No attached messages.\n";
exit;
}
$nested = new Email();
$i = 0;
while ($i < $wrapper->NumAttachedMessages) {
try {
$wrapper->GetAttachedEmail($i, $nested);
} catch (\Chilkat2\Exception $e) {
echo $e->getMessage(), "\n";
exit;
}
echo 'Original author: ', $nested->From, "\n";
echo 'Original subject: ', $nested->Subject, "\n";
echo 'Files on the original: ', $nested->NumAttachments, "\n";
$i = $i + 1;
}