$string = "Content-Type: text/plain\r\nSubject: Test\r\n\r\nMessage" $message = $mailParser-> parse( $handle, false) // returns `IMessage` // OR: use this procedurally (Message::from also accepts a string, // resource or Psr7 StreamInterface // true or false as second parameter doesn't matter if passing a string. parse() accepts a string, resource or Psr7 StreamInterface // pass `true` as the second argument to attach the passed $handle and close // it when the returned IMessage is destroyed. use an instance of MailMimeParser as a class dependency $mailParser = new MailMimeParser() Use ZBateson\ MailMimeParser\ Header\ HeaderConsts Use ZBateson\ MailMimeParser\ MailMimeParser This means reading only the headers from a larger message is as fast as a smaller message because the whole message is no longer parsed (similarly reading just the content and not a message's large attachments is also much faster.)īecause of the on-demand parsing, starting in 2.0, the passed resource handle or stream must remain open while the returned message object is still in use.
EMAIL PARSER ONLINE UPGRADE
Upgrade to 2.0 to take advantage of the new on-demand parser which parses parts of a message as they're requested. Note that getBinar圜ontentResourceHandle and getResourceHandle are still available. fread() will only return a single byte of a multibyte char, and so will cause potentially unexpected results/warnings in some cases, and psr7 streams should be used instead. GetContentResourceHandle, getTextResourceHandle, and getHtmlResourceHandle have all been deprecated in 1.2.1 and removed in 2.0.0. If this project's helped you, please consider sponsoring me. Composer require zbateson/mail-mime-parser