Example #1
0
function envelopes_to_xml($envelopes, $sentorreceived)
{
    $messagexml = '';
    foreach ($envelopes as $headerinfo) {
        $subject = $headerinfo["subject"];
        $imapdate = $headerinfo["date"];
        $phpdate = strtotime($imapdate);
        $date = date('Y-m-d H:i:s', $phpdate);
        $from = $headerinfo["from"];
        $fromcomponents = $from[0];
        $fromaddress = $fromcomponents["address"];
        $fromdisplay = $fromcomponents["display"];
        $sourcefolder = $sentorreceived;
        $to = $headerinfo["to"];
        $cc = $headerinfo["cc"];
        $bcc = $headerinfo["bcc"];
        $contenttext = "";
        $contenthtml = "";
        $sourceuid = $headerinfo['messageuid'];
        $messagexml .= "<message>\n";
        $messagexml .= make_tag("messageuid", uniqid("", TRUE));
        $messagexml .= make_cdatatag("sourceuid", $sourceuid);
        $messagexml .= make_cdatatag("subject", $subject);
        $messagexml .= make_cdatatag("fromaddress", $fromaddress);
        $messagexml .= make_cdatatag("fromdisplay", $fromdisplay);
        $messagexml .= make_tag("deliverytime", $date);
        $messagexml .= "<recipients>\n";
        $messagexml .= create_envelope_recipients_xml($to, "to");
        $messagexml .= create_envelope_recipients_xml($cc, "cc");
        $messagexml .= create_envelope_recipients_xml($bcc, "bcc");
        $messagexml .= "</recipients>\n";
        $messagexml .= make_cdatatag("contenttext", $contenttext);
        $messagexml .= make_cdatatag("contenthtml", $contenthtml);
        $messagexml .= make_tag("sourcefolder", $sourcefolder);
        $messagexml .= "</message>\n";
    }
    return $messagexml;
}
Example #2
0
function message_headers_to_xml($headers, $sentorreceived)
{
    $messagexml = '';
    foreach ($headers as $messageindex => $headermap) {
        $subject = ifsetor($headermap['subject'], '');
        $imapdate = ifsetor($headermap['date'], '');
        $phpdate = strtotime($imapdate);
        $date = date('Y-m-d H:i:s', $phpdate);
        $fromstring = ifsetor($headerinfo['from'], '');
        $fromparts = extract_address_from_string($fromstring);
        $fromaddress = $fromparts['address'];
        $fromdisplay = $fromparts['display'];
        $sourcefolder = $sentorreceived;
        $to = ifsetor($headermap["to"], '');
        $cc = ifsetor($headermap["cc"], '');
        $bcc = ifsetor($headermap["bcc"], '');
        $contenttext = '';
        $contenthtml = '';
        $sourceuid = $messageindex;
        $messagexml .= "<message>\n";
        $messagexml .= make_tag("messageuid", uniqid("", TRUE));
        $messagexml .= make_cdatatag("sourceuid", $sourceuid);
        $messagexml .= make_cdatatag("subject", $subject);
        $messagexml .= make_cdatatag("fromaddress", $fromaddress);
        $messagexml .= make_cdatatag("fromdisplay", $fromdisplay);
        $messagexml .= make_tag("deliverytime", $date);
        $messagexml .= "<recipients>\n";
        $messagexml .= create_header_recipients_xml($to, "to");
        $messagexml .= create_header_recipients_xml($cc, "cc");
        $messagexml .= create_header_recipients_xml($bcc, "bcc");
        $messagexml .= "</recipients>\n";
        $messagexml .= make_cdatatag("contenttext", $contenttext);
        $messagexml .= make_cdatatag("contenthtml", $contenthtml);
        $messagexml .= make_tag("sourcefolder", $sourcefolder);
        $messagexml .= "</message>\n";
    }
    return $messagexml;
}