Documentation

Attachment extends AbstractPart
in package

Attachment message part class

Tags
category

Pop

author

Nick Sagona, III dev@nolainteractive.com

copyright

Copyright (c) 2009-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com)

license

http://www.popphp.org/license New BSD License

version
4.0.0

Table of Contents

Constants

_7BIT  = '_7BIT'
_8BIT  = '_8BIT'
BASE64  = 'BASE64'
Encoding constants
BINARY  = 'BINARY'
QUOTED_PRINTABLE  = 'QUOTED_PRINTABLE'

Properties

$basename  : string|null
File attachment basename
$charSet  : string|null
Character set
$content  : string|null
Message part content
$contentType  : string|null
Content type
$contentTypes  : array<string|int, mixed>
Common content types for auto-detection
$encoding  : string|null
Message part encoding
$filename  : string|null
File attachment
$headers  : array<string|int, mixed>
Headers
$id  : string|null
Message or part ID
$idHeader  : string|null
Message or part ID header name
$stream  : string|null
File attachment original stream content

Methods

__construct()  : mixed
Constructor
__toString()  : string
Render message to string
addHeader()  : AbstractMessage
Add message part header
addHeaders()  : AbstractMessage
Add message part headers
createFromFile()  : Attachment
Create attachment from file
createFromStream()  : Attachment
Create attachment from stream
generateId()  : string
Generate a new ID
getBasename()  : string|null
Get attachment basename
getBody()  : string|null
Get body
getCharSet()  : string|null
Get message part character set
getContent()  : string|null
Get message part content
getContentType()  : string|null
Get message part content type
getEncoding()  : string|null
Get message part encoding
getFilename()  : string|null
Get attachment filename
getHeader()  : string|null
Get message part header
getHeaderAsString()  : string|null
Get header as string
getHeaders()  : array<string|int, mixed>
Get all message part headers
getHeadersAsString()  : string
Get all message headers as string
getId()  : string|null
Get the ID
getIdHeader()  : string|null
Get the ID
getStream()  : string|null
Get attachment original stream content
hasHeader()  : bool
Determine if message part has header
is7Bit()  : bool
Check if encoding is 7-bit
is8Bit()  : bool
Check if encoding is 8-bit
isBase64()  : bool
Check if encoding is base64
isQuotedPrintable()  : bool
Check if encoding is quoted printable
render()  : string
Render
renderAsLines()  : array<string|int, mixed>
Render as an array of lines
setCharSet()  : AbstractMessage
Set message part character set
setContent()  : AbstractPart
Set message part content
setContentType()  : AbstractMessage
Set message part content type
setEncoding()  : AbstractPart
Set message part encoding
setId()  : AbstractMessage
Set the ID
setIdHeader()  : AbstractMessage
Set the ID header name
getRandomId()  : string
Returns a random ID

Constants

BASE64

Encoding constants

public string BASE64 = 'BASE64'

QUOTED_PRINTABLE

public mixed QUOTED_PRINTABLE = 'QUOTED_PRINTABLE'

Properties

$basename

File attachment basename

protected string|null $basename = null

$content

Message part content

protected string|null $content = null

$contentTypes

Common content types for auto-detection

protected array<string|int, mixed> $contentTypes = ['csv' => 'text/csv', 'doc' => 'application/msword', 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'gif' => 'image/gif', 'html' => 'text/html', 'htm' => 'text/html', 'jpe' => 'image/jpeg', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'log' => 'text/plain', 'md' => 'text/plain', 'pdf' => 'application/pdf', 'png' => 'image/png', 'ppt' => 'application/vnd.ms-powerpoint', 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 'svg' => 'image/svg+xml', 'tif' => 'image/tiff', 'tiff' => 'image/tiff', 'tsv' => 'text/tsv', 'txt' => 'text/plain', 'xls' => 'application/vnd.ms-excel', 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'zip' => 'application/x-zip']

$encoding

Message part encoding

protected string|null $encoding = null

$filename

File attachment

protected string|null $filename = null

$idHeader

Message or part ID header name

protected string|null $idHeader = null

$stream

File attachment original stream content

protected string|null $stream = null

Methods

__construct()

Constructor

public __construct([string|null $file = null ][, string|null $stream = null ][, array<string|int, mixed> $options = [] ]) : mixed

Instantiate the mail attachment object

Parameters
$file : string|null = null
$stream : string|null = null
$options : array<string|int, mixed> = []

['contentType', 'basename', 'encoding', 'chunk']

Tags
throws
Exception

__toString()

Render message to string

public __toString() : string
Return values
string

createFromFile()

Create attachment from file

public static createFromFile(string $file[, array<string|int, mixed> $options = [] ]) : Attachment
Parameters
$file : string
$options : array<string|int, mixed> = []

['contentType', 'basename', 'encoding', 'chunk']

Return values
Attachment

createFromStream()

Create attachment from stream

public static createFromStream(string $stream[, array<string|int, mixed> $options = [] ]) : Attachment
Parameters
$stream : string
$options : array<string|int, mixed> = []

['contentType', 'basename', 'encoding', 'chunk']

Return values
Attachment

generateId()

Generate a new ID

public generateId([string|null $domain = null ]) : string
Parameters
$domain : string|null = null
Tags
string

?string $domain

Return values
string

getBasename()

Get attachment basename

public getBasename() : string|null
Return values
string|null

getBody()

Get body

public abstract getBody() : string|null
Return values
string|null

getCharSet()

Get message part character set

public getCharSet() : string|null
Return values
string|null

getContent()

Get message part content

public getContent() : string|null
Return values
string|null

getContentType()

Get message part content type

public getContentType() : string|null
Return values
string|null

getEncoding()

Get message part encoding

public getEncoding() : string|null
Return values
string|null

getFilename()

Get attachment filename

public getFilename() : string|null
Return values
string|null

getHeader()

Get message part header

public getHeader(string $header) : string|null
Parameters
$header : string
Return values
string|null

getHeaderAsString()

Get header as string

public getHeaderAsString(string $header) : string|null
Parameters
$header : string
Return values
string|null

getHeaders()

Get all message part headers

public getHeaders() : array<string|int, mixed>
Return values
array<string|int, mixed>

getHeadersAsString()

Get all message headers as string

public getHeadersAsString([array<string|int, mixed> $omitHeaders = [] ]) : string
Parameters
$omitHeaders : array<string|int, mixed> = []
Return values
string

getId()

Get the ID

public getId() : string|null
Return values
string|null

getIdHeader()

Get the ID

public getIdHeader() : string|null
Return values
string|null

getStream()

Get attachment original stream content

public getStream() : string|null
Return values
string|null

hasHeader()

Determine if message part has header

public hasHeader(string $header) : bool
Parameters
$header : string
Return values
bool

is7Bit()

Check if encoding is 7-bit

public is7Bit() : bool
Return values
bool

is8Bit()

Check if encoding is 8-bit

public is8Bit() : bool
Return values
bool

isBase64()

Check if encoding is base64

public isBase64() : bool
Return values
bool

isQuotedPrintable()

Check if encoding is quoted printable

public isQuotedPrintable() : bool
Return values
bool

render()

Render

public abstract render() : string
Return values
string

renderAsLines()

Render as an array of lines

public abstract renderAsLines() : array<string|int, mixed>
Return values
array<string|int, mixed>

getRandomId()

Returns a random ID

protected getRandomId([string|null $idRight = null ]) : string
Parameters
$idRight : string|null = null
Tags
string

?string $idRight

Return values
string

        
On this page

Search results