mailparse_determine_best_xfer_encoding

Gets the best way of encoding

说明

string 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 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 mailparse_msg_create ( 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 mailparse_msg_extract_part_file ( resource $mimemail , mixed $filename [, 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 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
  • mailparse_msg_extract_whole_part_file

mailparse_msg_extract_part

Extracts/decodes a message section

说明

void mailparse_msg_extract_part ( resource $mimemail , string $msgbody [, callable $callbackfunc ] )

Warning

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

参数

mimemail
A valid MIME resource.

msgbody

callbackfunc

返回值

没有返回值。

参见

  • mailparse_msg_extract_part_file
  • mailparse_msg_extract_whole_part_file

mailparse_msg_extract_whole_part_file

Extracts a message section including headers without decoding the transfer encoding

说明

string mailparse_msg_extract_whole_part_file ( resource $mimemail , string $filename [, 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 mailparse_msg_free ( resource $mimemail )

Frees a MIME resource.

参数

mimemail
A valid MIME resource allocated by mailparse_msg_create or 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 mailparse_msg_get_part_data ( resource $mimemail )

Warning

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

参数

mimemail
A valid MIME resource.

mailparse_msg_get_part

Returns a handle on a given section in a mimemessage

说明

resource mailparse_msg_get_part ( resource $mimemail , 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 mailparse_msg_get_structure ( resource $mimemail )

Warning

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

参数

mimemail
A valid MIME resource.

mailparse_msg_parse_file

Parses a file

说明

resource mailparse_msg_parse_file ( 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.

返回值

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 mailparse_msg_parse ( resource $mimemail , 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

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

mailparse_rfc822_parse_addresses

Parse RFC 822 compliant addresses

说明

array mailparse_rfc822_parse_addresses ( 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 <wez@example.com>, doe@example.com

Note:

This string must not include the header name.

返回值

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

displayThe recipient name, for display purpose. If this part is not set for a recipient, this key will hold the same value as address.
addressThe email address
is_groupTRUE if the recipient is a newsgroup, FALSE otherwise.

范例

示例 #1 mailparse_rfc822_parse_addresses example

<?php

$to = 'Wez Furlong <wez@example.com>, doe@example.com';
var_dump(mailparse_rfc822_parse_addresses($to));

?>

以上例程会输出:

array(2) {
  [0]=>
  array(3) {
    ["display"]=>
    string(11) "Wez Furlong"
    ["address"]=>
    string(15) "wez@example.com"
    ["is_group"]=>
    bool(false)
  }
  [1]=>
  array(3) {
    ["display"]=>
    string(15) "doe@example.com"
    ["address"]=>
    string(15) "doe@example.com"
    ["is_group"]=>
    bool(false)
  }
}

mailparse_stream_encode

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

说明

bool mailparse_stream_encode ( resource $sourcefp , resource $destfp , 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 mailparse_uudecode_all ( 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.

filenamePath to the temporary file name created
origfilenameThe 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: fred@example.com

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: fred@example.com

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

UUE (test.txt)
this is a test

目录