CkPhp Requires Chilkat v11.0.0+
CkPhp
Forward an email as an attachment
See more Email Object Examples
Attach the original Email to a new message as a message/rfc822 part. The recipient can open the attached email and read its original headers and body.
Chilkat CkPhp Downloads
<?php
include("chilkat.php");
$success = false;
// Assumes Chilkat is unlocked. See Global Unlock Sample.
$original = new CkEmail();
$success = $original->LoadEml('message.eml');
if ($success != true) {
print $original->lastErrorText() . "\n";
exit;
}
$email = new CkEmail();
$email->put_From('Sam Lee <sam@example.com>');
$success = $email->AddTo('Alex Rivera','alex@example.net');
if ($success != true) {
print $email->lastErrorText() . "\n";
exit;
}
$email->put_Subject('Forwarded message');
$email->put_Body('The original email is attached.');
$success = $email->AttachEmail($original);
if ($success != true) {
print $email->lastErrorText() . "\n";
exit;
}
$success = $email->SaveEml('forward-as-attachment.eml');
if ($success != true) {
print $email->lastErrorText() . "\n";
exit;
}
print 'Saved forward-as-attachment.eml.' . "\n";
?>