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

Read the recipient results in a delivery status report

See more Email Object Examples

Check the report type before reading DSN-specific fields. One report may describe multiple recipients. Retain the per-recipient information in GetDsnInfo instead of assigning one status to every delivery.

Chilkat CkPerl Downloads

CkPerl
use chilkat();

$success = 0;

#  Assumes Chilkat is unlocked. See Global Unlock Sample.

$email = chilkat::CkEmail->new();
$success = $email->LoadEml("delivery-status.eml");
if ($success != 1) {
    print $email->lastErrorText() . "\r\n";
    exit;
}

if ($email->IsMultipartReport() != 1) {
    print "This message is not a multipart report." . "\r\n";
    exit;
}

if ($email->GetNumPartsOfType("message/delivery-status",0,0) == 0) {
    print "No delivery-status part in this report." . "\r\n";
    exit;
}

if ($email->HasPlainTextBody() == 1) {
    print $email->getPlainTextBody() . "\r\n";
}

$details = chilkat::CkJsonObject->new();
$success = $email->GetDsnInfo($details);
if ($success != 1) {
    print $email->lastErrorText() . "\r\n";
    exit;
}

$details->put_EmitCompact(0);
print $details->emit() . "\r\n";