Ref/mailparse-Phpdoc专题

mailparse_determine_best_xfer_encoding

Gets the best way of encoding

说明

string <span class="methodname">mailparse_determine_best_xfer_encoding ( resource $fp )

Figures out the best way of encoding the content read from the given file pointer.

参数

fp
A valid file pointer, which must be seek-able.

返回值

Returns one of the character encodings supported by the mbstring module.

范例

示例 #1 <span class="function">mailparse_determine_best_xfer_encoding example

<?php

$fp = fopen('somemail.eml', 'r');
echo 'Best encoding: ' . mailparse_determine_best_xfer_encoding($fp);

?>

以上例程的输出类似于:

Best encoding: 7bit

mailparse_msg_create

Create a mime mail resource

说明

resource <span class="methodname">mailparse_msg_create ( <span class="methodparam">void )

Create a MIME mail resource.

返回值

Returns a handle that can be used to parse a message.

参见

  • mailparse_msg_free
  • mailparse_msg_parse_file

mailparse_msg_extract_part_file

Extracts/decodes a message section

说明

string <span class="methodname">mailparse_msg_extract_part_file ( <span class="methodparam">resource $mimemail , <span class="type">mixed $filename [, <span class="methodparam">callable $callbackfunc ] )

Extracts/decodes a message section from the supplied filename.

The contents of the section will be decoded according to their transfer encoding - base64, quoted-printable and uuencoded text are supported.

参数

mimemail
A valid MIME resource, created with <span class="function">mailparse_msg_create.

filename
Can be a file name or a valid stream resource.

callbackfunc
If set, this must be either a valid callback that will be passed the extracted section, or null to make this function return the extracted section.

If not specified, the contents will be sent to "stdout".

返回值

If callbackfunc is not null returns true on success.

If callbackfunc is set to null, returns the extracted section as a string.

Returns false on error.

参见

  • mailparse_msg_extract_part
  • <span class="function">mailparse_msg_extract_whole_part_file

mailparse_msg_extract_part

Extracts/decodes a message section

说明

void <span class="methodname">mailparse_msg_extract_part ( <span class="methodparam">resource $mimemail , <span class="type">string $msgbody [, <span class="methodparam">callable $callbackfunc ] )

Warning

本函数还未编写文档,仅有参数列表。

参数

mimemail
A valid MIME resource.

msgbody

callbackfunc

返回值

没有返回值。

参见

  • mailparse_msg_extract_part_file
  • <span class="function">mailparse_msg_extract_whole_part_file

mailparse_msg_extract_whole_part_file

Extracts a message section including headers without decoding the transfer encoding

说明

string <span class="methodname">mailparse_msg_extract_whole_part_file ( resource $mimemail , <span class="type">string $filename [, <span class="methodparam">callable $callbackfunc ] )

Warning

本函数还未编写文档,仅有参数列表。

参数

mimemail
A valid MIME resource.

filename

callbackfunc

返回值

参见

  • mailparse_msg_extract_part
  • mailparse_msg_extract_part_file

mailparse_msg_free

Frees a MIME resource

说明

bool <span class="methodname">mailparse_msg_free ( <span class="methodparam">resource $mimemail )

Frees a MIME resource.

参数

mimemail
A valid MIME resource allocated by <span class="function">mailparse_msg_create or <span class="function">mailparse_msg_parse_file.

返回值

成功时返回 true, 或者在失败时返回 false

参见

  • mailparse_msg_create
  • mailparse_msg_parse_file

mailparse_msg_get_part_data

Returns an associative array of info about the message

说明

array <span class="methodname">mailparse_msg_get_part_data ( <span class="methodparam">resource $mimemail )

Warning

本函数还未编写文档,仅有参数列表。

参数

mimemail
A valid MIME resource.

mailparse_msg_get_part

Returns a handle on a given section in a mimemessage

说明

resource <span class="methodname">mailparse_msg_get_part ( <span class="methodparam">resource $mimemail , <span class="type">string $mimesection )

Warning

本函数还未编写文档,仅有参数列表。

参数

mimemail
A valid MIME resource.

mimesection

mailparse_msg_get_structure

Returns an array of mime section names in the supplied message

说明

array <span class="methodname">mailparse_msg_get_structure ( <span class="methodparam">resource $mimemail )

Warning

本函数还未编写文档,仅有参数列表。

参数

mimemail
A valid MIME resource.

mailparse_msg_parse_file

Parses a file

说明

resource <span class="methodname">mailparse_msg_parse_file ( <span class="methodparam">string $filename )

Parses a file. This is the optimal way of parsing a mail file that you have on disk.

参数

filename
Path to the file holding the message. The file is opened and streamed through the parser.

Note:

The message contained in filename is supposed to end with a newline (CRLF); otherwise the last line of the message will not be parsed.

返回值

Returns a MIME resource representing the structure, or false on error.

参见

  • mailparse_msg_free
  • mailparse_msg_create

mailparse_msg_parse

Incrementally parse data into buffer

说明

bool <span class="methodname">mailparse_msg_parse ( <span class="methodparam">resource $mimemail , <span class="type">string $data )

Incrementally parse data into the supplied mime mail resource.

This function allow you to stream portions of a file at a time, rather than read and parse the whole thing.

参数

mimemail
A valid MIME resource.

data

Note:

The final chunk of data is supposed to end with a newline (CRLF); otherwise the last line of the message will not be parsed.

返回值

成功时返回 true, 或者在失败时返回 false

mailparse_rfc822_parse_addresses

Parse RFC 822 compliant addresses

说明

array <span class="methodname">mailparse_rfc822_parse_addresses ( <span class="methodparam">string $addresses )

Parses a » RFC 822 compliant recipient list, such as that found in the To: header.

参数

addresses
A string containing addresses, like in: Wez Furlong \<[email protected]>, [email protected]

Note:

This string must not include the header name.

返回值

Returns an array of associative arrays with the following keys for each recipient:

display The recipient name, for display purpose. If this part is not set for a recipient, this key will hold the same value as address.
address The email address
is_group true if the recipient is a newsgroup, false otherwise.

范例

示例 #1 <span class="function">mailparse_rfc822_parse_addresses example

<?php

$to = 'Wez Furlong <[email protected]>, [email protected]';
var_dump(mailparse_rfc822_parse_addresses($to));

?>

以上例程会输出:

array(2) {
  [0]=>
  array(3) {
    ["display"]=>
    string(11) "Wez Furlong"
    ["address"]=>
    string(15) "[email protected]"
    ["is_group"]=>
    bool(false)
  }
  [1]=>
  array(3) {
    ["display"]=>
    string(15) "[email protected]"
    ["address"]=>
    string(15) "[email protected]"
    ["is_group"]=>
    bool(false)
  }
}

mailparse_stream_encode

Streams data from source file pointer, apply encoding and write to destfp

说明

bool <span class="methodname">mailparse_stream_encode ( <span class="methodparam">resource $sourcefp , <span class="type">resource $destfp , <span class="methodparam">string $encoding )

Streams data from the source file pointer, apply encoding and write to the destination file pointer.

参数

sourcefp
A valid file handle. The file is streamed through the parser.

destfp
The destination file handle in which the encoded data will be written.

encoding
One of the character encodings supported by the mbstring module.

返回值

成功时返回 true, 或者在失败时返回 false

范例

示例 #1 mailparse_stream_encode example

<?php

// email.eml contents: hello, this is some text=hello.
$fp = fopen('email.eml', 'r');

$dest = tmpfile();

mailparse_stream_encode($fp, $dest, "quoted-printable");

rewind($dest);

// Display new file contents
fpassthru($dest);

?>

以上例程会输出:

hello, this is some text=3Dhello.

mailparse_uudecode_all

Scans the data from fp and extract each embedded uuencoded file

说明

array <span class="methodname">mailparse_uudecode_all ( <span class="methodparam">resource $fp )

Scans the data from the given file pointer and extract each embedded uuencoded file into a temporary file.

参数

fp
A valid file pointer.

返回值

Returns an array of associative arrays listing filename information.

filename Path to the temporary file name created
origfilename The original filename, for uuencoded parts only

The first filename entry is the message body. The next entries are the decoded uuencoded files.

范例

示例 #1 mailparse_uudecode_all example

<?php

$text = <<<EOD
To: [email protected]

hello, this is some text hello.
blah blah blah.

begin 644 test.txt
/=&AI<R!I<R!A('1E<W0*
`
end

EOD;

$fp = tmpfile();
fwrite($fp, $text);

$data = mailparse_uudecode_all($fp);

echo "BODY\n";
readfile($data[0]["filename"]);
echo "UUE ({$data[1]['origfilename']})\n";
readfile($data[1]["filename"]);

// Clean up
unlink($data[0]["filename"]);
unlink($data[1]["filename"]);

?>

以上例程会输出:

BODY
To: [email protected]

hello, this is some text hello.
blah blah blah.

UUE (test.txt)
this is a test

目录


本站为非盈利网站,作品由网友提供上传,如无意中有侵犯您的版权,请联系删除