Mail_IMAP
[ class tree: Mail_IMAP ] [ index: Mail_IMAP ] [ all elements ]

Class: Mail_IMAP

Source Location: /Mail_IMAP-1.0.0RC3/IMAP.php

Class Overview


Mail_IMAP provides a simplified backend for working with the c-client (IMAP) extension.


Author(s):

Version:

  • 1.0.0RC3

Copyright:

  • (c) Copyright 2004, Richard York, All Rights Reserved.

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 88]
Mail_IMAP provides a simplified backend for working with the c-client (IMAP) extension.

It serves as an OO wrapper for commonly used c-client functions. It provides structure and header parsing as well as body retrieval.

This package requires the c-client extension. To download the latest version of the c-client extension goto: http://www.php.net/imap.

PEAR PREREQUISITES: Net_URL (Required if you will be using a URI abstraction to connect.)

Known Bugs: Potential bugs may arise from the detection of certain multipart/* messages. Application parses and adjusts for anomalies in multipart/mixed, multipart/related and multipart/alternative messages. Bugs may arise from untested and unincluded multipart message types, multipart/parallel, multipart/report, multipart/signed and multipart/digest. If you happen across a problem related to one of the untested message types, please mail a copy of the message (if possible) to demo@smilingsouls.net where I may analyze the message structure and include it in the class. Be sure to include Mail_IMAP (multipart/*) in the subject line so that I know the message isn't SPAM and don't delete it.

Having trouble finding the example files? Examples are located in the PEAR install directory under /docs/Mail_IMAP/examples

Extended documentation available at: http://www.spicypeanut.net



[ Top ]


Class Variables

$attachFname =

[line 253]

(str) Attachment original file name (if any, if not file name is empty string).
  • Access: public

Type:   array


[ Top ]

$attachFsize =

[line 246]

(int) Attachment file size in bytes.
  • Access: public

Type:   array


[ Top ]

$attachFtype =

[line 239]

(str) Attachment MIME type.
  • Access: public

Type:   array


[ Top ]

$attachHasAttach =

[line 260]

(bool) Attachment has attachments?
  • Access: public

Type:   array


[ Top ]

$attachPid =

[line 232]

(str) Attachment part id.
  • Access: public

Type:   array


[ Top ]

$header =

[line 276]

(array)(mixed) Associative array containing information gathered by imap_headerinfo or imap_rfc822_parse_headers.
  • Var: array $header

Type:   header


[ Top ]

$inFname =

[line 210]

(int) Inline file name of the part, if any.
  • Access: public

Type:   array


[ Top ]

$inFsize =

[line 203]

(int) Inline file size of the part in bytes.
  • Access: public

Type:   array


[ Top ]

$inFtype =

[line 196]

(str) Inline part MIME type.
  • Access: public

Type:   array


[ Top ]

$inHasAttach =

[line 217]

(bool) Inline part has attachments?
  • Access: public

Type:   array


[ Top ]

$inInlineId =

[line 224]

(str) Inline CID for multipart/related.
  • Access: public

Type:   array


[ Top ]

$inPid =

[line 189]

(str) Inline part id.
  • Access: public

Type:   array


[ Top ]

$mailbox =

[line 96]

Contains the imap resource stream.
  • Access: public

Type:   resource


[ Top ]

$mailboxInfo =

[line 103]

Contains information about the current mailbox.
  • Access: public

Type:   array


[ Top ]

$rawHeaders =

[line 269]

(str) Contains raw message headers fetched from imap_fetchbody or imap_fetchheader depending on which message part is being retrieved.
  • Access: public

Type:   array


[ Top ]



Method Detail

Mail_IMAP (Constructor)   [line 294]

BOOL|NULL|PEAR_Error Mail_IMAP( [ $connection = NULL], [int $options = NULL], string $connect)

Constructor. Optionally set the IMAP resource stream.

If IMAP connection arguments are not supplied, returns NULL. Accepts a URI abstraction of the standard imap_open connection argument (see connect) or the imap resource indicator.


Parameters:

string   $connect   —  (optional) server URL to connect to
int   $options   —  (optional) options see imap_open
   $connection   — 

[ Top ]

alerts   [line 1441]

string|FALSE alerts( [string $seperator = "<br />\n"])

Wrapper function for imap_alerts. Implodes the array returned by imap_alerts, (if any) and returns the text.

Parameters:

string   $seperator   —  Characters to seperate each alert message. '
\n' by default.

[ Top ]

close   [line 406]

PEAR_Error|TRUE close( [int $options = NULL])

Wrapper method for imap_close. Close the IMAP resource stream.
  • See: imap_close
  • Access: public

Parameters:

int   $options   —  (optional) sets the second argument of imap_close

[ Top ]

connect   [line 358]

PEAR_Error|TRUE connect( string $connect, [int $options = NULL])

Wrapper method for imap_open. Accepts a URI abstraction in the following format: imap://user:pass@mail.example.com:143/INBOX#notls instead of the standard connection arguments used in imap_open.

Replace the protocol with one of pop3|pop3s imap|imaps nntp|nntps. Place intial folder in the file path portion, and optionally append tls|notls|novalidate-cert in the anchor portion of the URL. A port number is optional, however, leaving it off could lead to a serious degradation in preformance.

Examples of a well-formed connection argument:

For IMAP: imap://user:pass@mail.example.com:143/INBOX

For IMAP SSL: imaps://user:pass@example.com:993/INBOX

For POP3: pop3://user:pass@mail.example.com:110/INBOX

For POP3 SSL: pop3s://user:pass@mail.example.com:993/INBOX

For NNTP: nntp://user:pass@mail.example.com:119/comp.test

For 'notls' OR 'novalidate-cert' append to the URL as an anchor. For 'tls' use secure protocol and add the 'tls' option to the anchor.

Examples:

For notls: imap://user:pass@mail.example.com:143/INBOX#notls

For tls: imaps://user:pass@mail.example.com:143/INBOX#tls

tls no-validate: imaps://user:pass@mail.example.com:143/INBOX#tls/novalidate-cert

ssl no-validate: imaps://user:pass@mail.example.com:143/INBOX#novalidate-cert

If the username is an email address or contains invalid URL characters, urlencode the username portion of the string before passing it.

Use the IMAP.connection_wizard_example.php file to automatically detect the correct URI to pass to this function. This file is located in the examples directory.

  • See: imap_open
  • Access: public

Parameters:

string   $connect   —  server URL
int   $options   —  (optional) options

[ Top ]

convertBytes   [line 1359]

string convertBytes( int $bytes)

Converts an integer containing the number of bytes in a file to one of Bytes, Kilobytes, Megabytes, or Gigabytes, appending the unit of measurement.
  • Access: public

Parameters:

int   $bytes   — 

[ Top ]

delete   [line 1382]

TRUE|PEAR_Error delete( int &$mid, [ $separator = "<br />\n"])

Wrapper function for imap_delete. Sets the marked for deletion flag. Note: POP3 mailboxes do not remember flag settings between connections, for POP3 mailboxes this function should be used in addtion to expunge.

Parameters:

int   &$mid   —  message id
   $separator   — 

[ Top ]

errors   [line 1423]

string|FALSE errors( [string $seperator = "<br />\n"])

Wrapper function for imap_errors. Implodes the array returned by imap_errors, (if any) and returns the error text.

Parameters:

string   $seperator   —  Characters to seperate each error message. '
\n' by default.

[ Top ]

expunge   [line 1406]

TRUE|PEAR_Error expunge( )

Wrapper function for imap_expunge. Expunges messages marked for deletion.

[ Top ]

extractMIME   [line 1088]

array|FALSE extractMIME( int &$mid, string $MIME)

Searches all message parts for the specified MIME type. Use getBody with $action option MAIL_IMAP_LITERAL_DECODE to view MIME type parts retrieved.

If you need to access the MIME type with filename use normal getBody with no action specified.

Returns an array of part ids on success. Returns FALSE if MIME couldn't be found, or on failure.

  • Access: public

Parameters:

int   &$mid   —  message id
string   $MIME   —  mime type to extract

[ Top ]

getBody   [line 916]

array|string|FALSE getBody( int &$mid, string $pid, [int $action = 0], [string $getPart = 'text/html'], [int $options = NULL], [ $attempt = 1])

Searches parts array set in Mail_IMAP::_declareParts() for a displayable message.

If the part id passed is message/rfc822 looks in subparts for a displayable body. Attempts to return a text/html inline message part by default. And will automatically attempt to find a text/plain part if a text/html part could not be found.

Returns an array containing three associative indices; 'ftype', 'fname' and 'message'. 'ftype' contains the MIME type of the message, 'fname', the original file name, if any, empty string otherwise. And 'message', which contains the message body itself which is returned decoded from base64 or quoted-printable if either of those encoding types are specified, returns untouched otherwise. Returns FALSE on failure.

  • See: Mail_IMAP::getParts
  • See: imap_fetchbody
  • Since: PHP 4.2.0
  • Access: public

Parameters:

int   &$mid   —  message id
string   $pid   —  part id
int   $action   —  (optional) options for body return. Set to one of the following: MAIL_IMAP_BODY (default), if part is message/rfc822 searches subparts for a displayable body and returns the body decoded as part of an array. MAIL_IMAP_LITERAL, return the message for the specified $pid without searching subparts or decoding the message (may return unparsed message) body is returned undecoded as a string. MAIL_IMAP_LITERAL_DECODE, same as MAIL_IMAP_LITERAL, except message decoding is attempted from base64 or quoted-printable encoding, returns undecoded string if decoding failed.
string   $getPart   —  (optional) one of text/plain or text/html, allows the specification of the default part to return from multipart messages, text/html by default.
int   $options   —  (optional) allows the specification of the forth argument of imap_fetchbody
   $attempt   — 

[ Top ]

getDefaultPid   [line 1011]

string getDefaultPid( int &$mid, [string $getPart = 'text/html'], [ $attempt = 1])

Searches structure defined in Mail_IMAP::_declareParts for the top-level default message.

Attempts to find a text/html default part, if no text/html part is found, automatically attempts to find a text/plain part. Returns the part id for the default top level message part on success. Returns FALSE on failure.

  • Access: public

Parameters:

int   &$mid   —  message id
string   $getPart   —  (optional) default MIME type to look for, one of text/html or text/plain text/html by default.
   $attempt   — 

[ Top ]

getHeaders   [line 1171]

BOOL getHeaders( int &$mid, string &$pid, [int $from_length = 1024], [int $subject_length = 1024], [string $default_host = NULL], [int $options = NULL])

Set member variable containing header information. Creates an array containing associative indices referring to various header information. Use http://www.php.net/var_dump or http://www.php.net/print_r on the $header member variable to view information gathered by this function.
  • See: imap_headerinfo
  • See: imap_rfc822_parse_headers
  • See: imap_fetchbody
  • See: imap_fetchheader
  • See: Mail_IMAP::getParts()
  • Access: public

Parameters:

int   &$mid   —  message id
string   &$pid   —  part id
int   $from_length   —  (optional) from length for imap_headerinfo
int   $subject_length   —  (optional) subject length for imap_headerinfo
string   $default_host   —  (optional) default host for imap_headerinfo & imap_rfc822_parse_headers
int   $options   —  (optional) flags/options for imap_fetchbody

[ Top ]

getParts   [line 619]

bool getParts( int &$mid, int &$pid, [string $MIME = 'text/html'], [bool $getAlternative = TRUE])

sets up member variables containing inline parts and attachments for a specific part in member variable arrays beginning with 'in' and 'attach'.

If inline parts are present, sets $inPid, $inFtype, $inFsize, $inHasAttach, $inInlineId (if an inline CID is specified). If attachments are present, sets, $attachPid, $attachFsize, $attachHasAttach, $attachFname (if a filename is present, empty string otherwise).

Typically the text/html part is displayed by default by a message viewer, this part is excluded from the inline member variable arrays thourgh $excludeMime by default. If $getInline is TRUE the text/plain alternative part will be returned in the inline array and may be included as an attachment. Useful for mail developement/debugging of multipart messages.

  • Since: PHP 4.2.0
  • Access: public

Parameters:

int   &$mid   —  message id
int   &$pid   —  part id
string   $MIME   —  (optional) values: text/plain|text/html, the part MIME type that will be retrieved by default.
bool   $getAlternative   —  (optional) include the plain text alternative part in the created inline parts array.

[ Top ]

getQuota   [line 1460]

array|PEAR_Error getQuota( [string $folder = 'INBOX'])

Retreives information about the current mailbox's quota. Rounds up quota sizes and appends the unit of measurment. Returns information in a multi-dimensional associative array.
  • See: imap_get_quotaroot
  • Throws: Quota not available on this server. Remedy: none.
  • Access: public

Parameters:

string   $folder   —  Folder to retrieve quota for.

[ Top ]

getRawHeaders   [line 1133]

string|FALSE getRawHeaders( int &$mid, string $pid, [int $options = NULL])

Set member variable $rawHeaders to contain Raw Header information for a part. Returns default header part id on success, returns FALSE on failure.

Parameters:

int   &$mid   —  message_id
string   $pid   —  part id
int   $options   —  flags/options for imap_fetchbody

[ Top ]

getRawMessage   [line 869]

void getRawMessage( int &$mid, [int $options = NULL])

Returns entire unparsed message body. See imap_body for options.
  • See: imap_body
  • Access: public

Parameters:

int   &$mid   —  message id
int   $options   —  flags

[ Top ]

messageCount   [line 427]

int messageCount( )

Wrapper method for imap_num_msg. Calling on this function will reset the IMAP error stack (if mailbox is empty). imap_errors is called to supress a NOTICE level error, mailbox is empty, which isn't an error state. For debugging, comment out the call to imap_errors.
  • Return: mailbox message count
  • See: imap_num_msg
  • Access: public

[ Top ]

setFlags   [line 1501]

BOOL|PEAR_Error setFlags( array $mids, array $flags, [int $action = 3], [int $options = NULL])

Wrapper function for imap_setflag_full. Sets various message flags.

Accepts an array of message ids and an array of flags to be set.

The flags which you can set are "\\Seen", "\\Answered", "\\Flagged", "\\Deleted", and "\\Draft" (as defined by RFC2060).

Warning: POP3 mailboxes do not remember flag settings from connection to connection.

  • See: imap_clearflag_full
  • See: imap_setflag_full
  • Throws: Message IDs and Flags are to be supplied as arrays. Remedy: place message ids and flags in arrays.
  • Access: public

Parameters:

array   $mids   —  Array of message ids to set flags on.
array   $flags   —  Array of flags to set on messages.
int   $action   —  Flag operation toggle one of MAIL_IMAP_SET_FLAGS (default) or MAIL_IMAP_CLEAR_FLAGS.
int   $options   —  (optional) sets the forth argument of imap_setflag_full or {@imap_clearflag_full}.

[ Top ]

unsetHeaders   [line 1342]

void unsetHeaders( int &$mid)

Destroys variables set by getHeaders.

Parameters:

int   &$mid   —  message id

[ Top ]

unsetParts   [line 774]

void unsetParts( integer &$mid)

Destroys variables set by getParts and _declareParts.

Parameters:

integer   &$mid   —  message id

[ Top ]


Documentation generated on Mon, 11 Mar 2019 10:15:02 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.