Imap_Attachment object handles messages attachments from Imap_Message class

Attachment objects are automatically generated when found in the Imap_Message class in the Imap_Message::getParts() function. Attachments are identified, but not downloaded until requested, similar to the Imap_Message class.

category Email
package Imap
author Tim Withers
copyright 2012 Tim Withers
license PHP License 3.01
version 1.0

 Methods

Construct populates basic info about the email attachment

__construct(\id $parent, int $part, object $data) 

Does not fetch the attachment at this point.

Parameters

$parent

\id

$part

int

$data

object

Magic __get() returns requested data

__get(\type $name) : boolean

Connection is fetched from base class. Fetches attachment when content or decoded content is requested. Content type can also be fetched.

Parameters

$name

\type

Returns

booleanFALSE if not found, else value of parameter requested

Download the attachment

download() 

Modifies header information to output an email attachment.

Gets a literal version of the content type

getAttachmentType(int $type, string $subtype) : string
Inherited

Some examples would be: 'application/pdf' 'image/png' 'application/octet-stream'

inherited_from \Imap_Base::getAttachmentType()

Parameters

$type

int

Integer representing 1 of 8 main types

$subtype

string

Specified subtype

Returns

string

Lazy loading check to see if attachment has been fetched

checkFetched() : null

Attachment loaded if flag is false

Returns

null

Decodes a string based on encoding types.

decode(string $string, int $type) : string
Inherited

Types are declared in numeric format in the headers of each part. Each part has to be decoded for readability.

inherited_from \Imap_Base::decode()

Parameters

$string

string

To be decoded

$type

int

Returns

string

Returns static connection resource

getConnection() : resource
Inherited

Since connection is static, all subclasses do not need to reconnect and there is no need to pass the resource into the child classes from the main Imap class

inherited_from \Imap_Base::getConnection()

Returns

resourceConnection

Sets the connection property

setConnection(resource $con) 
Inherited
inherited_from \Imap_Base::setConnection()

Parameters

$con

resource

 Properties

 

$attachmentFetched : bool
 

$data : object
 

$part : int
 

$connection 
Inherited

This is set from the Imap class

static Connection to Imap server
inherited_from \Imap_Base::$$connection
 

$content : string

Not populated until requested.

 

$decodedData : string
 

$parent : int

Used in fetching attachment data.