Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get data from this object? 1

Status
Not open for further replies.

cmayo

MIS
Apr 23, 2001
159
US
I'm using ezcMail to parse incoming email and can't figure out how to get the references and in-reply-to headers (highlighted below) from the object returned by the parser (below). Can anyone tell me how to do that?

PHP:
object(ezcMail)#13 (5) {
  ["options":protected]=>
  object(ezcMailOptions)#20 (1) {
    ["properties":protected]=>
    array(1) {
      ["stripBccHeader"]=>
      bool(false)
    }
  }
  ["headers":"ezcMailPart":private]=>
  object(ezcMailHeadersHolder)#19 (2) {
    ["lookup":"ezcMailHeadersHolder":private]=>
    array(16) {
      ["return-path"]=>
      string(11) "Return-path"
      ["envelope-to"]=>
      string(11) "Envelope-to"
      ["delivery-date"]=>
      string(13) "Delivery-date"
      ["received"]=>
      string(8) "Received"
      ["from"]=>
      string(4) "From"
      ["to"]=>
      string(2) "To"
      ["references"]=>
      string(10) "References"
      ["in-reply-to"]=>
      string(11) "In-Reply-To"
      ["subject"]=>
      string(7) "Subject"
      ["date"]=>
      string(4) "Date"
      ["message-id"]=>
      string(10) "Message-ID"
      ["mime-version"]=>
      string(12) "MIME-Version"
      ["content-type"]=>
      string(12) "Content-Type"
      ["x-mailer"]=>
      string(8) "X-Mailer"
      ["thread-index"]=>
      string(12) "Thread-Index"
      ["content-language"]=>
      string(16) "Content-Language"
    }
    ["map":"ezcMailHeadersHolder":private]=>
    array(16) {
      ["Return-path"]=>
      string(21) ""
      ["Envelope-to"]=>
      array(1) {
        [0]=>
        string(26) "8568@tickets.com"
      }
      ["Delivery-date"]=>
      array(1) {
        [0]=>
        string(31) "Wed, 09 Oct 2013 17:13:30 -0700"
      }
      ["Received"]=>
      array(1) {
        [0]=>
        string(263) ""
      }
      ["From"]=>
      string(34) ""
      ["To"]=>
      string(64) ""'Field Response'" <8568@tickets.com>"
     [highlight #FCE94F] ["References"]=>
      string(45) "8568_20131009171233_1381363953@com"
      ["In-Reply-To"]=>
      string(45) "8568_20131009171233_1381363953@com"[/highlight]
      ["Subject"]=>
      string(96) "RE: Work Order #8568"
      ["Date"]=>
      string(30) "Wed, 9 Oct 2013 19:12:42 -0500"
      ["Message-ID"]=>
      string(37) "<009f01cec54d$70a3f4f0$51ebded0$@com>"
      ["MIME-Version"]=>
      array(1) {
        [0]=>
        string(3) "1.0"
      }
      ["Content-Type"]=>
      string(75) "multipart/alternative; boundary="----=_NextPart_000_00A0_01CEC523.87CDECF0""
      ["X-Mailer"]=>
      array(1) {
        [0]=>
        string(29) "Microsoft Office Outlook 12.0"
      }
      ["Thread-Index"]=>
      array(1) {
        [0]=>
        string(36) "Ac7FTWp8l4sBmiF8Ra6+47KhZ/rlpwAAAfhw"
      }
      ["Content-Language"]=>
      array(1) {
        [0]=>
        string(5) "en-us"
      }
    }
  }
  ["headerCharsets":"ezcMailPart":private]=>
  array(16) {
    ["Return-path"]=>
    string(8) "us-ascii"
    ["Envelope-to"]=>
    string(8) "us-ascii"
    ["Delivery-date"]=>
    string(8) "us-ascii"
    ["Received"]=>
    string(8) "us-ascii"
    ["From"]=>
    string(8) "us-ascii"
    ["To"]=>
    string(8) "us-ascii"
    ["References"]=>
    string(8) "us-ascii"
    ["In-Reply-To"]=>
    string(8) "us-ascii"
    ["Subject"]=>
    string(8) "us-ascii"
    ["Date"]=>
    string(8) "us-ascii"
    ["Message-ID"]=>
    string(8) "us-ascii"
    ["MIME-Version"]=>
    string(8) "us-ascii"
    ["Content-Type"]=>
    string(8) "us-ascii"
    ["X-Mailer"]=>
    string(8) "us-ascii"
    ["Thread-Index"]=>
    string(8) "us-ascii"
    ["Content-Language"]=>
    string(8) "us-ascii"
  }
  ["excludeHeaders":"ezcMailPart":private]=>
  array(0) {
  }
  ["properties":protected]=>
  array(10) {
    ["from"]=>
    object(ezcMailAddress)#21 (3) {
      ["name"]=>
      string(10) ""
      ["email"]=>
      string(19) ""
      ["charset"]=>
      string(5) "utf-8"
    }
    ["to"]=>
    array(1) {
      [0]=>
      object(ezcMailAddress)#22 (3) {
        ["name"]=>
        string(33) ""
        ["email"]=>
        string(26) ""
        ["charset"]=>
        string(5) "utf-8"
      }
    }
    ["cc"]=>
    array(0) {
    }
    ["bcc"]=>
    array(0) {
    }
    ["subject"]=>
    string(96) ""
    ["subjectCharset"]=>
    string(5) "utf-8"
    ["body"]=>
    object(ezcMailMultipartAlternative)#11 (5) {
      ["parts":protected]=>
      array(2) {
        [0]=>
        object(ezcMailText)#15 (4) {
          ["headers":"ezcMailPart":private]=>
          object(ezcMailHeadersHolder)#16 (2) {
            ["lookup":"ezcMailHeadersHolder":private]=>
            array(2) {
              ["content-type"]=>
              string(12) "Content-Type"
              ["content-transfer-encoding"]=>
              string(25) "Content-Transfer-Encoding"
            }
            ["map":"ezcMailHeadersHolder":private]=>
            array(2) {
              ["Content-Type"]=>
              string(30) "text/plain; charset="us-ascii""
              ["Content-Transfer-Encoding"]=>
              string(4) "7bit"
            }
          }
          ["headerCharsets":"ezcMailPart":private]=>
          array(2) {
            ["Content-Type"]=>
            string(8) "us-ascii"
            ["Content-Transfer-Encoding"]=>
            string(8) "us-ascii"
          }
          ["excludeHeaders":"ezcMailPart":private]=>
          array(0) {
          }
          ["properties":protected]=>
          array(6) {
            ["text"]=>
            string(2218) ""
            ["charset"]=>
            string(5) "utf-8"
            ["encoding"]=>
            string(4) "8bit"
            ["subType"]=>
            string(5) "plain"
            ["originalCharset"]=>
            string(8) "us-ascii"
            ["size"]=>
            int(2218)
          }
        }
        [1]=>
        object(ezcMailText)#17 (4) {
          ["headers":"ezcMailPart":private]=>
          object(ezcMailHeadersHolder)#18 (2) {
            ["lookup":"ezcMailHeadersHolder":private]=>
            array(2) {
              ["content-type"]=>
              string(12) "Content-Type"
              ["content-transfer-encoding"]=>
              string(25) "Content-Transfer-Encoding"
            }
            ["map":"ezcMailHeadersHolder":private]=>
            array(2) {
              ["Content-Type"]=>
              string(29) "text/html; charset="us-ascii""
              ["Content-Transfer-Encoding"]=>
              string(16) "quoted-printable"
            }
          }
          ["headerCharsets":"ezcMailPart":private]=>
          array(2) {
            ["Content-Type"]=>
            string(8) "us-ascii"
            ["Content-Transfer-Encoding"]=>
            string(8) "us-ascii"
          }
          ["excludeHeaders":"ezcMailPart":private]=>
          array(0) {
          }
          ["properties":protected]=>
          array(6) {
            ["text"]=>
            string(4822) ""
            ["charset"]=>
            string(5) "utf-8"
            ["encoding"]=>
            string(4) "8bit"
            ["subType"]=>
            string(4) "html"
            ["originalCharset"]=>
            string(8) "us-ascii"
            ["size"]=>
            int(4822)
          }
        }
      }
      ["headers":"ezcMailPart":private]=>
      object(ezcMailHeadersHolder)#12 (2) {
        ["lookup":"ezcMailHeadersHolder":private]=>
        array(1) {
          ["content-type"]=>
          string(12) "Content-Type"
        }
        ["map":"ezcMailHeadersHolder":private]=>
        array(1) {
          ["Content-Type"]=>
          string(75) "multipart/alternative; boundary="----=_NextPart_000_00A0_01CEC523.87CDECF0""
        }
      }
      ["headerCharsets":"ezcMailPart":private]=>
      array(1) {
        ["Content-Type"]=>
        string(8) "us-ascii"
      }
      ["excludeHeaders":"ezcMailPart":private]=>
      array(0) {
      }
      ["properties":protected]=>
      array(3) {
        ["noMimeMessage"]=>
        string(136) "This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible."
        ["boundary"]=>
        string(41) "----=_NextPart_000_00A0_01CEC523.87CDECF0"
        ["size"]=>
        int(7040)
      }
    }
    ["messageId"]=>
    string(37) "<009f01cec54d$70a3f4f0$51ebded0$@com>"
    ["returnPath"]=>
    object(ezcMailAddress)#23 (3) {
      ["name"]=>
      string(0) ""
      ["email"]=>
      string(19) ""
      ["charset"]=>
      string(5) "utf-8"
    }
    ["size"]=>
    int(8560)
  }
}
 
I wrote a complex email parsing class a few years ago. I spent a long time trying to thread emails based on UIDs and in-relpy-to's etc etc. Disastrous - clients don't seem to adhere to standards

however - that is not your question ...

assuming that the paste is a var_dump of a standard object then addressing the bits directly will be difficult as they are private properties of the ezcMailHeadersHolder object.

to access private properties you would need to edit the class and change them to public. or build a method to access it.

from looking briefly at the documentation there does appear to be a method to do this. so try

Code:
echo '<pre>'; 
echo $object->getHeader('In-Reply-To') . "\n";
echo $object->getHeader('References');

where $object is a reference to your mail object.

but in honesty I have not come across eczmail before, have not downloaded the source nor taken a full look at it; so I'm quite probably wrong.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top