1 | <?php |
||
21 | class MailMimeParser |
||
22 | { |
||
23 | /** |
||
24 | * @var \ZBateson\MailMimeParser\SimpleDi dependency injection container |
||
25 | */ |
||
26 | protected $di; |
||
27 | |||
28 | /** |
||
29 | * Sets up the parser. |
||
30 | */ |
||
31 | public function __construct() |
||
35 | |||
36 | /** |
||
37 | * Parses the passed stream handle into a ZBateson\MailMimeParser\Message |
||
38 | * object and returns it. |
||
39 | * |
||
40 | * Internally, the message is first copied to a temp stream (with php://temp |
||
41 | * which may keep it in memory or write it to disk) and its stream is used. |
||
42 | * That way if the message is too large to hold in memory it can be written |
||
43 | * to a temporary file if need be. |
||
44 | * |
||
45 | * @param resource $handle the resource handle to the input stream of the |
||
46 | * mime message |
||
47 | * @param bool $isSmtp if set to true, treats the message as a raw message |
||
48 | * from SMTP, ending input on the first ".\r\n" it finds and |
||
49 | * replacing ".." at the beginning of a line with a single ".". |
||
50 | * @return \ZBateson\MailMimeParser\Message |
||
51 | */ |
||
52 | public function parse($handle, $isSmtp = false) |
||
61 | |||
62 | /** |
||
63 | * Replaces lines starting with '..' with a single dot. Returns false if a |
||
64 | * line containing a single '.' character is found signifying the last line |
||
65 | * of the input stream. |
||
66 | * |
||
67 | * @param string $line |
||
68 | * @return boolean |
||
69 | */ |
||
70 | private function filterSmtpLines(&$line) |
||
79 | |||
80 | /** |
||
81 | * Copies the input stream $inHandle into the $tmpHandle resource. |
||
82 | * Optionally treats the input as an SMTP input message with $isSmtp, |
||
83 | * considering end of input to be the first ".\r\n" it encounters. |
||
84 | * |
||
85 | * @param resource $tmpHandle the temporary resource handle |
||
86 | * @param resource $inHandle the input stream resource handle |
||
87 | * @param bool $isSmtp set to true if $inHandle is an SMTP input stream |
||
88 | */ |
||
89 | protected function copyToTmpFile($tmpHandle, $inHandle, $isSmtp) |
||
100 | } |
||
101 |