PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 5.7.2
Defender Security – Malware Scanner, Login Security & Firewall v5.7.2
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
defender-security / vendor / thecodingmachine / safe / generated / mailparse.php

mailparse.php in Defender Security – Malware Scanner, Login Security & Firewall 5.7.2, at vendor/thecodingmachine/safe/generated/mailparse.php

128 lines 3.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Safe;
4
5 use Safe\Exceptions\MailparseException;
6
7 /**
8 * Extracts/decodes a message section from the supplied filename.
9 *
10 * The contents of the section will be decoded according to their transfer
11 * encoding - base64, quoted-printable and uuencoded text are supported.
12 *
13 * @param resource $mimemail A valid MIME resource, created with
14 * mailparse_msg_create.
15 * @param mixed $filename Can be a file name or a valid stream resource.
16 * @param callable $callbackfunc If set, this must be either a valid callback that will be passed the
17 * extracted section, or NULL to make this function return the
18 * extracted section.
19 *
20 * If not specified, the contents will be sent to "stdout".
21 * @return string If callbackfunc is not NULL returns TRUE on
22 * success.
23 *
24 * If callbackfunc is set to NULL, returns the
25 * extracted section as a string.
26 * @throws MailparseException
27 *
28 */
29 function mailparse_msg_extract_part_file($mimemail, $filename, callable $callbackfunc = null): string
30 {
31 error_clear_last();
32 if ($callbackfunc !== null) {
33 $result = \mailparse_msg_extract_part_file($mimemail, $filename, $callbackfunc);
34 } else {
35 $result = \mailparse_msg_extract_part_file($mimemail, $filename);
36 }
37 if ($result === false) {
38 throw MailparseException::createFromPhpError();
39 }
40 return $result;
41 }
42
43
44 /**
45 * Frees a MIME resource.
46 *
47 * @param resource $mimemail A valid MIME resource allocated by
48 * mailparse_msg_create or
49 * mailparse_msg_parse_file.
50 * @throws MailparseException
51 *
52 */
53 function mailparse_msg_free($mimemail): void
54 {
55 error_clear_last();
56 $result = \mailparse_msg_free($mimemail);
57 if ($result === false) {
58 throw MailparseException::createFromPhpError();
59 }
60 }
61
62
63 /**
64 * Parses a file.
65 * This is the optimal way of parsing a mail file that you have on disk.
66 *
67 * @param string $filename Path to the file holding the message.
68 * The file is opened and streamed through the parser.
69 *
70 * The message contained in filename is supposed to end with a newline
71 * (CRLF); otherwise the last line of the message will not be parsed.
72 * @return resource Returns a MIME resource representing the structure.
73 * @throws MailparseException
74 *
75 */
76 function mailparse_msg_parse_file(string $filename)
77 {
78 error_clear_last();
79 $result = \mailparse_msg_parse_file($filename);
80 if ($result === false) {
81 throw MailparseException::createFromPhpError();
82 }
83 return $result;
84 }
85
86
87 /**
88 * Incrementally parse data into the supplied mime mail resource.
89 *
90 * This function allow you to stream portions of a file at a time, rather
91 * than read and parse the whole thing.
92 *
93 * @param resource $mimemail A valid MIME resource.
94 * @param string $data The final chunk of data is supposed to end with a newline
95 * (CRLF); otherwise the last line of the message will not be parsed.
96 * @throws MailparseException
97 *
98 */
99 function mailparse_msg_parse($mimemail, string $data): void
100 {
101 error_clear_last();
102 $result = \mailparse_msg_parse($mimemail, $data);
103 if ($result === false) {
104 throw MailparseException::createFromPhpError();
105 }
106 }
107
108
109 /**
110 * Streams data from the source file pointer, apply
111 * encoding and write to the destination file pointer.
112 *
113 * @param resource $sourcefp A valid file handle. The file is streamed through the parser.
114 * @param resource $destfp The destination file handle in which the encoded data will be written.
115 * @param string $encoding One of the character encodings supported by the
116 * mbstring module.
117 * @throws MailparseException
118 *
119 */
120 function mailparse_stream_encode($sourcefp, $destfp, string $encoding): void
121 {
122 error_clear_last();
123 $result = \mailparse_stream_encode($sourcefp, $destfp, $encoding);
124 if ($result === false) {
125 throw MailparseException::createFromPhpError();
126 }
127 }
128