(PHP Extension) Iterate Email Headers
Demonstrates how to iterate over the email header fields.
<?php
// The version number (9_5_0) should match version of the Chilkat extension used, omitting the micro-version number.
// For example, if using Chilkat v9.5.0.48, then include as shown here:
include("chilkat_9_5_0.php");
$email = new CkEmail();
// First, load an email from a file.
// Note: an email object may be loaded from a file, or
// downloaded directly from a POP3 or IMAP server...
$success = $email->LoadEml('testReceivedHdrs.eml');
if ($success != true) {
print $email->lastErrorText() . "\n";
exit;
}
// How many header fields?
$n = $email->get_NumHeaderFields();
if ($n > 0) {
// Display the name and value of each header:
for ($i = 0; $i <= $n - 1; $i++) {
$name = $email->getHeaderFieldName($i);
$value = $email->getHeaderFieldValue($i);
print $i . "\n";
print $name . "\n";
print $value . "\n";
}
}
?>
|