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 = 'base64', string $type = 'application/octet-stream') : boolean

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.

Returns

boolean

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($custom_header) : void
access public

Parameters

$custom_header

Adds an embedded attachment. 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".

AddEmbeddedImage(string $path, string $cid, string $name = '', string $encoding = 'base64', string $type = 'application/octet-stream') : boolean

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

boolean

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 = 'base64', string $type = 'application/octet-stream') : 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.

AddStringEmbeddedImage()

AddStringEmbeddedImage($string, $cid, $filename = '', $encoding = 'base64', $type = 'application/octet-stream'

Parameters

$string

$cid

$filename

$encoding

$type

Creates recipient headers.

AddrAppend($type, $addr) : string
access public

Parameters

$type

$addr

Returns

string

Formats an address correctly.

AddrFormat($addr) : string
access public

Parameters

$addr

Returns

string

AlternativeExists()

AlternativeExists() 

AttachmentExists()

AttachmentExists() 

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

Base64EncodeWrapMB(string $str) : string
access public

Parameters

$str

string

multi-byte text to wrap encode

Returns

string

Clears all recipients assigned in the TO array. Returns void.

ClearAddresses() : void

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

ClearAllRecipients() : void

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

ClearAttachments() : void

Clears all recipients assigned in the BCC array. Returns void.

ClearBCCs() : void

Clears all recipients assigned in the CC array. Returns void.

ClearCCs() : void

Clears all custom headers. Returns void.

ClearCustomHeaders() : void

Clears all recipients assigned in the ReplyTo array. Returns void.

ClearReplyTos() : void

Assembles the message body. Returns an empty string on failure.

CreateBody() : string
access public

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) 
access public

Parameters

$headers_line

string

Header lines

$subject

string

Subject

$body

string

Body

Generate DKIM Canonicalization Body

DKIM_BodyC(string $body) 
access public

Parameters

$body

string

Message Body

Generate DKIM Canonicalization Header

DKIM_HeaderC(string $s) 
access public

Parameters

$s

string

Header

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

DKIM_QP($txt) 
access public

Parameters

$txt

Generate DKIM signature

DKIM_Sign(string $s) 
access public

Parameters

$s

string

Header

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

EncodeHeader($str, $position = 'text') : string
access public

Parameters

$str

$position

Returns

string

Encode string to q encoding.

EncodeQ(string $str, string $position = 'text') : 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 = 76, boolean $space_conv = false) : string
see
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

Encode string to quoted-printable.

EncodeQPphp($input = '', integer $line_max = 76, $space_conv = false) : string

Only uses standard PHP, slow, but will always work

access public

Parameters

$input

$line_max

integer

Number of chars allowed on a line before wrapping

$space_conv

Returns

string

Encodes string to requested format.

EncodeString(string $str, string $encoding = 'base64') : 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 CR or LF to CRLF.

FixEOL($str) : string
access public

Parameters

$str

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). Only really valid post PreSend().

GetSentMIMEMessage() : string
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) : boolean
access public

Parameters

$str

string

multi-byte text to wrap encode

Returns

boolean

Returns a formatted header line.

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

Parameters

$name

$value

Returns

string

Returns true if an inline attachment is present.

InlineImageExists() : boolean
access public

Returns

boolean

Returns true if an error occurred.

IsError() : boolean
access public

Returns

boolean

Sets message type to HTML.

IsHTML(boolean $ishtml = true) : void

Parameters

$ishtml

boolean

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($message, $basedir = '') : \$message
access public

Parameters

$message

$basedir

Returns

\$message

Returns the proper RFC 822 formatted date.

RFCDate() : string
Static
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. If the message is not sent successfully then it returns false. Use the ErrorInfo variable to view description of the error.

Send() : boolean

Returns

boolean

Set the From and FromName properties

SetFrom(string $address, string $name = '', $auto = 1) : boolean

Parameters

$address

string

$name

string

$auto

Returns

boolean

Sets the language for all class error messages.

SetLanguage(string $langcode = 'en', string $lang_path = 'language/'

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

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() : boolean

Returns false if the operation failed.

uses
access public

Returns

boolean

Returns a formatted mail line.

TextLine($value) : string
access public

Parameters

$value

Returns

string

Finds last character boundary prior to maxLength in a utf-8 quoted (printable) encoded string.

UTF8CharBoundary(string $encodedText, integer $maxLength) : integer

Original written by Colin Brown.

access public

Parameters

$encodedText

string

utf-8 QP text

$maxLength

integer

find last character boundary prior to this length

Returns

integer

Check that a string looks roughly like an email address should Static so it can be used without instantiation Tries to use PHP built-in validator in the filter extension (from PHP 5.2), falls back to a reasonably competent regex validator Conforms approximately to RFC2822

ValidateAddress(string $address) : boolean
Static
link Original pattern found here
static
access public

Parameters

$address

string

The email address to check

Returns

boolean

Wraps message for use with mailers that do not automatically perform wrapping and for quoted-printable.

WrapText(string $message, integer $length, boolean $qp_mode = false) : string

Original written by philippe.

access public

Parameters

$message

string

The message to wrap

$length

integer

The line length to wrap to

$qp_mode

boolean

Whether to run in Quoted-Printable mode

Returns

string

Constructor

__construct(boolean $exceptions = false

Parameters

$exceptions

boolean

Should we throw external exceptions?

Gets the MIME type of the embedded or inline image

_mime_types(string $ext = '') : string
Static
access public
static

Parameters

$ext

string

File extension

Returns

stringMIME type of ext

Set (or reset) Class Objects (variables)

set(string $name, mixed $value = ''

Usage Example: $page->set('X-Priority', '3');

access public
todo Should this not be using __set() magic function?

Parameters

$name

string

Parameter Name

$value

mixed

Parameter Value NOTE: will not work with arrays, there are no arrays to set/reset

Adds an address to one of the recipient arrays Addresses that have been added already return false, but do not throw exceptions

AddAnAddress(string $kind, string $address, string $name = '') : boolean
access protected

Parameters

$kind

string

One of 'to', 'cc', 'bcc', 'ReplyTo'

$address

string

The email address to send to

$name

string

Returns

booleantrue on success, false if address already used or invalid in some way

Attaches all fs, string, and binary attachments to the message.

AttachAll($disposition_type, $boundary) : string

Returns an empty string on failure.

access protected

Parameters

$disposition_type

$boundary

Returns

string

Encodes attachment in requested format.

EncodeFile(string $path, string $encoding = 'base64') : string

Returns an empty string on failure.

see
access protected

Parameters

$path

string

The full path to the file

$encoding

string

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

Returns

string

Returns the end of a message boundary.

EndBoundary($boundary) : string
access protected

Parameters

$boundary

Returns

string

Returns the start of a message boundary.

GetBoundary($boundary, $charSet, $contentType, $encoding) : string
access protected

Parameters

$boundary

$charSet

$contentType

$encoding

Returns

string

Returns a message in the appropriate language.

Lang($key) : string
access protected

Parameters

$key

Returns

string

Sends mail using the PHP mail() function.

MailSend(string $header, string $body) : boolean
access protected

Parameters

$header

string

The message headers

$body

string

The message body

Returns

boolean

PostSend()

PostSend() 

PreSend()

PreSend() 

Sends mail using the $Sendmail program.

SendmailSend(string $header, string $body) : boolean
access protected

Parameters

$header

string

The message headers

$body

string

The message body

Returns

boolean

Returns the server hostname or 'localhost.localdomain' if unknown.

ServerHostname() : string
access protected

Returns

string

Adds the error message to the error container.

SetError($msg) : void
access protected

Parameters

$msg

Sets the message type.

SetMessageType() : void
access protected

Sends mail via SMTP using PhpSMTP Returns false if there is a bad MAIL FROM, RCPT, or DATA input.

SmtpSend(string $header, string $body) : boolean
uses
access protected

Parameters

$header

string

The message headers

$body

string

The message body

Returns

boolean

doCallback()

doCallback($isSent, $to, $cc, $bcc, $subject, $body) 

Parameters

$isSent

$to

$cc

$bcc

$subject

$body

 Properties

 

Sets the text-only body of the message. This automatically sets the email to multipart/alternative. This body can be read by mail clients that do not have HTML email capability such as mutt. Clients that can read HTML will view the normal Body.

$AltBody : string

Default

''
 

Sets the Body of the message. This can be either an HTML or text body.

$Body : string

Default

''

If HTML then run IsHTML(true).

 

Sets the CharSet of the message.

$CharSet : string

Default

'iso-8859-1'
 

Sets the email address that a reading confirmation will be sent.

$ConfirmReadingTo : string

Default

''
 

Sets the Content-type of the message.

$ContentType : string

Default

'text/plain'
 

Used with DKIM DNS Resource Record optional, in format of email address 'you@yourdomain.com'

$DKIM_domain : string

Default

''
 

Used with DKIM DNS Resource Record optional, in format of email address 'you@yourdomain.com'

$DKIM_identity : string

Default

''
 

Used with DKIM DNS Resource Record

$DKIM_passphrase : string

Default

''
 

Used with DKIM DNS Resource Record optional, in format of email address 'you@yourdomain.com'

$DKIM_private : string

Default

''
 

Used with DKIM DNS Resource Record

$DKIM_selector : string

Default

'phpmailer'
 

Sets the Encoding of the message. Options for this are "8bit", "7bit", "binary", "base64", and "quoted-printable".

$Encoding : string

Default

'8bit'
 

Holds the most recent mailer error message.

$ErrorInfo : string

Default

''
 

Sets the From email address for the message.

$From : string

Default

'root@localhost'
 

Sets the From name of the message.

$FromName : string

Default

'Root User'
 

Sets the SMTP HELO of the message (Default is $Hostname).

$Helo : string

Default

''
 

Sets the SMTP hosts. All hosts must be separated by a semicolon. You can also specify a different port for each host by using this format: [hostname:port] (e.g. "smtp1.example.com:25;smtp2.example.com").

$Host : string

Default

'localhost'

Hosts will be tried in order.

 

Sets the hostname to use in Message-Id and Received headers and as default HELO string. If empty, the value returned by SERVER_NAME is used or 'localhost.localdomain'.

$Hostname : string

Default

''
 

Provides the ability to change the line ending

$LE : string

Default

"\n"
 

Method to send mail: ("mail", "sendmail", or "smtp").

$Mailer : string

Default

'mail'
 

Sets the message ID to be used in the Message-Id header.

$MessageID : string

Default

''

If empty, a unique id will be generated.

 

Sets SMTP password.

$Password : string

Default

''
 

Path to PHPMailer plugins. Useful if the SMTP class is in a different directory than the PHP include path.

$PluginDir : string

Default

''
 

Sets the default SMTP server port.

$Port : integer

Default

25
 

Email priority (1 = High, 3 = Normal, 5 = low).

$Priority : integer

Default

3
 

Sets SMTP authentication. Utilizes the Username and Password variables.

$SMTPAuth : boolean

Default

false
 

Sets SMTP class debugging on or off.

$SMTPDebug : boolean

Default

false
 

Prevents the SMTP connection from being closed after each mail sending. If this is set to true then to close the connection requires an explicit call to SmtpClose().

$SMTPKeepAlive : boolean

Default

false
 

Sets connection prefix.

$SMTPSecure : string

Default

''

Options are "", "ssl" or "tls"

 

Sets the Sender email (Return-Path) of the message. If not empty, will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.

$Sender : string

Default

''
 

Sets the path of the sendmail program.

$Sendmail : string

Default

'/usr/sbin/sendmail'
 

Provides the ability to have the TO field process individual emails, instead of sending to entire TO addresses

$SingleTo : boolean

Default

false
 

If SingleTo is true, this provides the array to hold the email addresses

$SingleToArray : boolean

Default

array()
 

Sets the Subject of the message.

$Subject : string

Default

''
 

Sets the SMTP server timeout in seconds.

$Timeout : integer

Default

10

This function will not work with the win32 version.

 

Sets SMTP username.

$Username : string

Default

''
 

Sets the PHPMailer Version number

$Version : string

Default

'5.2.1'
 

Sets word wrapping on the body of the message to a given number of characters.

$WordWrap : integer

Default

0
 

What to use in the X-Mailer header

$XMailer : string

Default

''
 

Callback Action function name the function that handles the result of the send email action. Parameters: bool $result result of the send action string $to email address of the recipient string $cc cc email addresses string $bcc bcc email addresses string $subject the subject string $body the email body

$action_function : string

Default

''
 

$CustomHeader

$CustomHeader 

Default

array()
 

Stores the complete compiled MIME message body.

$MIMEBody : string

Default

''
access protected
 

Stores the complete compiled MIME message headers.

$MIMEHeader : string

Default

''
access protected
 

$ReplyTo

$ReplyTo 

Default

array()
 

Stores the complete sent MIME message (Body and Headers)

$SentMIMEMessage : string

Default

''
access protected
 

$all_recipients

$all_recipients 

Default

array()
 

$attachment

$attachment 

Default

array()
 

$bcc

$bcc 

Default

array()
 

$boundary

$boundary 

Default

array()
 

$cc

$cc 

Default

array()
 

$error_count

$error_count 

Default

0
 

$exceptions

$exceptions 

Default

false
 

$language

$language 

Default

array()
 

$message_type

$message_type 

Default

''
 

$sign_cert_file

$sign_cert_file 

Default

''
 

$sign_key_file

$sign_key_file 

Default

''
 

$sign_key_pass

$sign_key_pass 

Default

''
 

$smtp

$smtp 

Default

NULL
 

$to

$to 

Default

array()

 Constants

 

STOP_CONTINUE

STOP_CONTINUE = 1 
 

STOP_CRITICAL

STOP_CRITICAL = 2 
 

STOP_MESSAGE

STOP_MESSAGE = 0