PHP email creation and transport class

package PHPMailer

 Methods

Adds a "To" address.

AddAddress(string $address, string $name) : boolean

Parameters

$address

string

$name

string

Returns

booleantrue on success, false if address already used

Adds an attachment from a path on the filesystem.

AddAttachment(string $path, string $name, string $encoding, string $type) : bool

Returns false if the file could not be found or accessed.

Parameters

$path

string

Path to the attachment.

$name

string

Overrides the attachment name.

$encoding

string

File encoding (see $Encoding).

$type

string

File extension (MIME) type.

Exceptions

\phpmailerException

Returns

bool

Adds a "Bcc" address.

AddBCC(string $address, string $name) : boolean

Note: this function works with the SMTP mailer on win32, not with the "mail" mailer.

Parameters

$address

string

$name

string

Returns

booleantrue on success, false if address already used

Adds a "Cc" address.

AddCC(string $address, string $name) : boolean

Note: this function works with the SMTP mailer on win32, not with the "mail" mailer.

Parameters

$address

string

$name

string

Returns

booleantrue on success, false if address already used

Adds a custom header.

AddCustomHeader(string $name, string $value) : void

$name value can be overloaded to contain both header name and value (name:value)

access public

Parameters

$name

string

custom header name

$value

string

header value

Adds an embedded attachment.

AddEmbeddedImage(string $path, string $cid, string $name, string $encoding, string $type) : bool

This can include images, sounds, and just about any other document. Make sure to set the $type to an image type. For JPEG images use "image/jpeg" and for GIF images use "image/gif".

Parameters

$path

string

Path to the attachment.

$cid

string

Content ID of the attachment. Use this to identify the Id for accessing the image in an HTML form.

$name

string

Overrides the attachment name.

$encoding

string

File encoding (see $Encoding).

$type

string

File extension (MIME) type.

Returns

bool

Adds a "Reply-to" address.

AddReplyTo(string $address, string $name) : boolean

Parameters

$address

string

$name

string

Returns

boolean

Adds a string or binary attachment (non-filesystem) to the list.

AddStringAttachment(string $string, string $filename, string $encoding, string $type) : void

This method can be used to attach ascii or binary data, such as a BLOB record from a database.

Parameters

$string

string

String attachment data.

$filename

string

Name of the attachment.

$encoding

string

File encoding (see $Encoding).

$type

string

File extension (MIME) type.

Adds an embedded stringified attachment.

AddStringEmbeddedImage(string $string, string $cid, string $name, string $encoding, string $type) : bool

This can include images, sounds, and just about any other document. Make sure to set the $type to an image type. For JPEG images use "image/jpeg" and for GIF images use "image/gif".

Parameters

$string

string

The attachment.

$cid

string

Content ID of the attachment. Use this to identify the Id for accessing the image in an HTML form.

$name

string

Overrides the attachment name.

$encoding

string

File encoding (see $Encoding).

$type

string

File extension (MIME) type.

Returns

bool

Creates recipient headers.

AddrAppend(string $type, array $addr) : string

access public

Parameters

$type

string

$addr

array

Returns

string

Formats an address correctly.

AddrFormat(string $addr) : string

access public

Parameters

$addr

string

Returns

string

Does this message have an alternative body set?

AlternativeExists() : bool

Returns

bool

Returns true if an attachment (non-inline) is present.

AttachmentExists() : bool

Returns

bool

Correctly encodes and wraps long multibyte strings for mail headers without breaking lines within a character.

Base64EncodeWrapMB(string $str, string $lf) : string

Adapted from a function by paravoid at http://uk.php.net/manual/en/function.mb-encode-mimeheader.php

access public

Parameters

$str

string

multi-byte text to wrap encode

$lf

string

string to use as linefeed/end-of-line

Returns

string

Clears all recipients assigned in the TO array.

ClearAddresses() : void

Returns void.

Clears all recipients assigned in the TO, CC and BCC array.

ClearAllRecipients() : void

Returns void.

Clears all previously set filesystem, string, and binary attachments.

ClearAttachments() : void

Returns void.

Clears all recipients assigned in the BCC array.

ClearBCCs() : void

Returns void.

Clears all recipients assigned in the CC array.

ClearCCs() : void

Returns void.

Clears all custom headers.

ClearCustomHeaders() : void

Returns void.

Clears all recipients assigned in the ReplyTo array.

ClearReplyTos() : void

Returns void.

Assembles the message body.

CreateBody() : string

Returns an empty string on failure.

access public

Exceptions

\phpmailerException

Returns

stringThe assembled message body

Assembles message header.

CreateHeader() : string

access public

Returns

stringThe assembled header

Create the DKIM header, body, as new header

DKIM_Add(string $headers_line, string $subject, string $body) : string

access public

Parameters

$headers_line

string

Header lines

$subject

string

Subject

$body

string

Body

Returns

string

Generate DKIM Canonicalization Body

DKIM_BodyC(string $body) : string

access public

Parameters

$body

string

Message Body

Returns

string

Generate DKIM Canonicalization Header

DKIM_HeaderC(string $s) : string

access public

Parameters

$s

string

Header

Returns

string

Set the private key file and password to sign the message.

DKIM_QP(string $txt) : string

access public

Parameters

$txt

string

Returns

string

Generate DKIM signature

DKIM_Sign(string $s) : string

access public

Parameters

$s

string

Header

Returns

string

Encode a header string to best (shortest) of Q, B, quoted or none.

EncodeHeader(string $str, string $position) : string

access public

Parameters

$str

string

$position

string

Returns

string

Encode string to q encoding.

EncodeQ(string $str, string $position) : string

link http://tools.ietf.org/html/rfc2047
access public

Parameters

$str

string

the text to encode

$position

string

Where the text is going to be used, see the RFC for what that means

Returns

string

Encode string to RFC2045 (6.7) quoted-printable format Uses a PHP5 stream filter to do the encoding about 64x faster than the old version Also results in same content as you started with after decoding

EncodeQP(string $string, integer $line_max, boolean $space_conv) : string

see \global\EncodeQPphp()
access public
author Marcus Bointon

Parameters

$string

string

the text to encode

$line_max

integer

Number of chars allowed on a line before wrapping

$space_conv

boolean

Dummy param for compatibility with existing EncodeQP function

Returns

string

Encodes string to requested format.

EncodeString(string $str, string $encoding) : string

Returns an empty string on failure.

access public

Parameters

$str

string

The text to encode

$encoding

string

The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable'

Returns

string

Changes every end of line from CRLF, CR or LF to $this->LE.

FixEOL(string $str) : string

access public

Parameters

$str

string

String to FixEOL

Returns

string

Return the current array of attachments

GetAttachments() : array

Returns

array

Returns the message MIME.

GetMailMIME() : string

access public

Returns

string

Returns the MIME message (headers and body).

GetSentMIMEMessage() : string

Only really valid post PreSend().

access public

Returns

string

Return the current array of language strings

GetTranslations() : array

Returns

array

Checks if a string contains multibyte characters.

HasMultiBytes(string $str) : bool

access public

Parameters

$str

string

multi-byte text to wrap encode

Returns

bool

Returns a formatted header line.

HeaderLine(string $name, string $value) : string

access public

Parameters

$name

string

$value

string

Returns

string

Returns true if an inline attachment is present.

InlineImageExists() : bool

access public

Returns

bool

Returns true if an error occurred.

IsError() : bool

access public

Returns

bool

Sets message type to HTML.

IsHTML(bool $ishtml) : void

Parameters

$ishtml

bool

Sets Mailer to send message using PHP mail() function.

IsMail() : void

Sets Mailer to send message using the qmail MTA.

IsQmail() : void

Sets Mailer to send message using SMTP.

IsSMTP() : void

Sets Mailer to send message using the $Sendmail program.

IsSendmail() : void

Evaluates the message and returns modifications for inline images and backgrounds

MsgHTML(string $message, string $basedir) : string

access public

Parameters

$message

string

Text to be HTML modified

$basedir

string

baseline directory for path

Returns

string$message

Actual Email transport function Send the email via the selected mechanism

PostSend() : bool

Exceptions

\phpmailerException

Returns

bool

Prep mail by constructing all message entities

PreSend() : bool

Exceptions

\phpmailerException

Returns

bool

Returns the proper RFC 822 formatted date.

RFCDate() : string

access public
static

Returns

string

Strips newlines to prevent header injection.

SecureHeader(string $str) : string

access public

Parameters

$str

string

String

Returns

string

Creates message and assigns Mailer.

Send() : bool

If the message is not sent successfully then it returns false. Use the ErrorInfo variable to view description of the error.

Exceptions

\phpmailerException

Returns

bool

Set the From and FromName properties

SetFrom(string $address, string $name, int $auto) : boolean

Parameters

$address

string

$name

string

$auto

int

Also set Reply-To and Sender

Exceptions

\phpmailerException

Returns

boolean

Sets the language for all class error messages.

SetLanguage(string $langcode, string $lang_path) : bool

Returns false if it cannot load the language file. The default language is English.

access public

Parameters

$langcode

string

ISO 639-1 2-character language code (e.g. Portuguese: "br")

$lang_path

string

Path to the language file directory

Returns

bool

Set the body wrapping.

SetWordWrap() : void

access public

Set the private key file and password to sign the message.

Sign($cert_filename, string $key_filename, string $key_pass) 

access public

Parameters

$cert_filename

$key_filename

string

Parameter File Name

$key_pass

string

Password for private key

Closes the active SMTP session if one exists.

SmtpClose() : void

Initiates a connection to an SMTP server.

SmtpConnect() : bool