class PHPMailer


Located at : UKNOWVA_ROOT/libraries/phpmailer/phpmailer.php

Constants

STOP_MESSAGE

STOP_CONTINUE

STOP_CRITICAL

Properties

int $Priority Email priority (1 = High, 3 = Normal, 5 = low).
string $CharSet Sets the CharSet of the message.
string $ContentType Sets the Content-type of the message.
string $Encoding Sets the Encoding of the message. Options for this are "8bit", "7bit", "binary", "base64", and "quoted-printable".
string $ErrorInfo Holds the most recent mailer error message.
string $From Sets the From email address for the message.
string $FromName Sets the From name of the message.
string $Sender 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.
string $Subject Sets the Subject of the message.
string $Body Sets the Body of the message. This can be either an HTML or text body.
string $AltBody 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.
int $WordWrap Sets word wrapping on the body of the message to a given number of characters.
string $Mailer Method to send mail: ("mail", "sendmail", or "smtp").
string $Sendmail Sets the path of the sendmail program.
string $PluginDir Path to PHPMailer plugins. Useful if the SMTP class is in a different directory than the PHP include path.
string $ConfirmReadingTo Sets the email address that a reading confirmation will be sent.
string $Hostname 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'.
string $MessageID Sets the message ID to be used in the Message-Id header.
string $Host 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").
int $Port Sets the default SMTP server port.
string $Helo Sets the SMTP HELO of the message (Default is $Hostname).
string $SMTPSecure Sets connection prefix.
bool $SMTPAuth Sets SMTP authentication. Utilizes the Username and Password variables.
string $Username Sets SMTP username.
string $Password Sets SMTP password.
int $Timeout Sets the SMTP server timeout in seconds.
bool $SMTPDebug Sets SMTP class debugging on or off.
bool $SMTPKeepAlive 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().
bool $SingleTo Provides the ability to have the TO field process individual emails, instead of sending to entire TO addresses
bool $SingleToArray If SingleTo is true, this provides the array to hold the email addresses
string $LE Provides the ability to change the line ending
string $DKIM_selector Used with DKIM DNS Resource Record
string $DKIM_identity Used with DKIM DNS Resource Record optional, in format of email address 'you@yourdomain.com'
string $DKIM_domain Used with DKIM DNS Resource Record optional, in format of email address 'you@yourdomain.com'
string $DKIM_private Used with DKIM DNS Resource Record optional, in format of email address 'you@yourdomain.com'
string $action_function 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
string $Version Sets the PHPMailer Version number

Methods

__construct(boolean $exceptions = false)

Constructor

void
IsHTML(bool $ishtml = true)

Sets message type to HTML.

void
IsSMTP()

Sets Mailer to send message using SMTP.

void
IsMail()

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

void
IsSendmail()

Sets Mailer to send message using the $Sendmail program.

void
IsQmail()

Sets Mailer to send message using the qmail MTA.

boolean
AddAddress(string $address, string $name = '')

Adds a "To" address.

boolean
AddCC(string $address, string $name = '')

Adds a "Cc" address.

boolean
AddBCC(string $address, string $name = '')

Adds a "Bcc" address.

boolean
AddReplyTo(string $address, string $name = '')

Adds a "Reply-to" address.

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

Set the From and FromName properties

static boolean
ValidateAddress(string $address)

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

bool
Send()

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.

bool
SmtpConnect()

Initiates a connection to an SMTP server.

void
SmtpClose()

Closes the active SMTP session if one exists.

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

Sets the language for all class error messages.

array
GetTranslations()

Return the current array of language strings

string
AddrAppend($type, $addr)

Creates recipient headers.

string
AddrFormat($addr)

Formats an address correctly.

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

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

int
UTF8CharBoundary(string $encodedText, int $maxLength)

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

void
SetWordWrap()

Set the body wrapping.

string
CreateHeader()

Assembles message header.

string
GetMailMIME()

Returns the message MIME.

string
CreateBody()

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

string
HeaderLine($name, $value)

Returns a formatted header line.

string
TextLine($value)

Returns a formatted mail line.

bool
AddAttachment(string $path, string $name = '', string $encoding = 'base64', string $type = 'application/octet-stream')

Adds an attachment from a path on the filesystem.

array
GetAttachments()

Return the current array of attachments

string
EncodeString(string $str, string $encoding = 'base64')

Encodes string to requested format.

string
EncodeHeader($str, $position = 'text')

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

bool
HasMultiBytes(string $str)

Checks if a string contains multibyte characters.

string
Base64EncodeWrapMB(string $str)

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

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

Encode string to quoted-printable.

string
EncodeQP(string $string, integer $line_max = 76, boolean $space_conv = false)

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

string
EncodeQ(string $str, string $position = 'text')

Encode string to q encoding.

void
AddStringAttachment(string $string, string $filename, string $encoding = 'base64', string $type = 'application/octet-stream')

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

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

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".

bool
InlineImageExists()

Returns true if an inline attachment is present.

void
ClearAddresses()

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

void
ClearCCs()

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

void
ClearBCCs()

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

void
ClearReplyTos()

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

void
ClearAllRecipients()

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

void
ClearAttachments()

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

void
ClearCustomHeaders()

Clears all custom headers. Returns void.

static string
RFCDate()

Returns the proper RFC 822 formatted date.

bool
IsError()

Returns true if an error occurred.

void
AddCustomHeader($custom_header)

Adds a custom header.

$message
MsgHTML($message, $basedir = '')

Evaluates the message and returns modifications for inline images and backgrounds

static string
_mime_types(string $ext = '')

Gets the MIME type of the embedded or inline image

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

Set (or reset) Class Objects (variables)

string
SecureHeader(string $str)

Strips newlines to prevent header injection.

Sign($cert_filename, $key_filename, $key_pass)

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

DKIM_QP($txt)

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

DKIM_Sign(string $s)

Generate DKIM signature

DKIM_HeaderC(string $s)

Generate DKIM Canonicalization Header

DKIM_BodyC(string $body)

Generate DKIM Canonicalization Body

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

Create the DKIM header, body, as new header

Details

at line 342
__construct(boolean $exceptions = false)

Constructor

Parameters

boolean $exceptions Should we throw external exceptions?

at line 351
void IsHTML(bool $ishtml = true)

Sets message type to HTML.

Parameters

bool $ishtml

Return Value

void

at line 363
void IsSMTP()

Sets Mailer to send message using SMTP.

Return Value

void

at line 371
void IsMail()

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

Return Value

void

at line 379
void IsSendmail()

Sets Mailer to send message using the $Sendmail program.

Return Value

void

at line 390
void IsQmail()

Sets Mailer to send message using the qmail MTA.

Return Value

void

at line 407
boolean AddAddress(string $address, string $name = '')

Adds a "To" address.

Parameters

string $address
string $name

Return Value

boolean true on success, false if address already used

at line 418
boolean AddCC(string $address, string $name = '')

Adds a "Cc" address.

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

Parameters

string $address
string $name

Return Value

boolean true on success, false if address already used

at line 429
boolean AddBCC(string $address, string $name = '')

Adds a "Bcc" address.

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

Parameters

string $address
string $name

Return Value

boolean true on success, false if address already used

at line 439
boolean AddReplyTo(string $address, string $name = '')

Adds a "Reply-to" address.

Parameters

string $address
string $name

Return Value

boolean

at line 488
boolean SetFrom($address, $name = '', $auto = 1)

Set the From and FromName properties

Parameters

$address
$name
$auto

Return Value

boolean

at line 523
static boolean ValidateAddress(string $address)

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

Parameters

string $address The email address to check

Return Value

boolean

at line 545
bool Send()

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.

Return Value

bool

at line 797
bool SmtpConnect()

Initiates a connection to an SMTP server.

Returns false if the operation failed.

Return Value

bool

at line 859
void SmtpClose()

Closes the active SMTP session if one exists.

Return Value

void

at line 875
SetLanguage(string $langcode = 'en', string $lang_path = 'language/')

Sets the language for all class error messages.

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

Parameters

string $langcode ISO 639-1 2-character language code (e.g. Portuguese: "br")
string $lang_path Path to the language file directory

at line 909
array GetTranslations()

Return the current array of language strings

Return Value

array

at line 922
string AddrAppend($type, $addr)

Creates recipient headers.

Parameters

$type
$addr

Return Value

string

at line 939
string AddrFormat($addr)

Formats an address correctly.

Parameters

$addr

Return Value

string

at line 957
string WrapText(string $message, integer $length, boolean $qp_mode = false)

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

Original written by philippe.

Parameters

string $message The message to wrap
integer $length The line length to wrap to
boolean $qp_mode Whether to run in Quoted-Printable mode

Return Value

string

at line 1039
int UTF8CharBoundary(string $encodedText, int $maxLength)

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

Original written by Colin Brown.

Parameters

string $encodedText utf-8 QP text
int $maxLength find last character boundary prior to this length

Return Value

int

at line 1077
void SetWordWrap()

Set the body wrapping.

Return Value

void

at line 1098
string CreateHeader()

Assembles message header.

Return Value

string The assembled header

at line 1181
string GetMailMIME()

Returns the message MIME.

Return Value

string

at line 1215
string CreateBody()

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

Return Value

string The assembled message body

at line 1342
string HeaderLine($name, $value)

Returns a formatted header line.

Parameters

$name
$value

Return Value

string

at line 1351
string TextLine($value)

Returns a formatted mail line.

Parameters

$value

Return Value

string

at line 1369
bool AddAttachment(string $path, string $name = '', string $encoding = 'base64', string $type = 'application/octet-stream')

Adds an attachment from a path on the filesystem.

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

Parameters

string $path Path to the attachment.
string $name Overrides the attachment name.
string $encoding File encoding (see $Encoding).
string $type File extension (MIME) type.

Return Value

bool

at line 1407
array GetAttachments()

Return the current array of attachments

Return Value

array

at line 1516
string EncodeString(string $str, string $encoding = 'base64')

Encodes string to requested format.

Returns an empty string on failure.

Parameters

string $str The text to encode
string $encoding The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable'

Return Value

string

at line 1547
string EncodeHeader($str, $position = 'text')

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

Parameters

$str
$position

Return Value

string

at line 1608
bool HasMultiBytes(string $str)

Checks if a string contains multibyte characters.

Parameters

string $str multi-byte text to wrap encode

Return Value

bool

at line 1624
string Base64EncodeWrapMB(string $str)

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

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

Parameters

string $str multi-byte text to wrap encode

Return Value

string

at line 1664
string EncodeQPphp($input = '', $line_max = 76, $space_conv = false)

Encode string to quoted-printable.

Only uses standard PHP, slow, but will always work

Parameters

$input
$line_max
$space_conv

Return Value

string

at line 1717
string EncodeQP(string $string, integer $line_max = 76, boolean $space_conv = false)

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

Parameters

string $string the text to encode
integer $line_max Number of chars allowed on a line before wrapping
boolean $space_conv Dummy param for compatibility with existing EncodeQP function

Return Value

string

See also

EncodeQPphp()

at line 1746
string EncodeQ(string $str, string $position = 'text')

Encode string to q encoding.

Parameters

string $str the text to encode
string $position Where the text is going to be used, see the RFC for what that means

Return Value

string

at line 1781
void AddStringAttachment(string $string, string $filename, string $encoding = 'base64', string $type = 'application/octet-stream')

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

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.
string $filename Name of the attachment.
string $encoding File encoding (see $Encoding).
string $type File extension (MIME) type.

Return Value

void

at line 1808
bool AddEmbeddedImage(string $path, string $cid, string $name = '', string $encoding = 'base64', string $type = 'application/octet-stream')

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".

Parameters

string $path Path to the attachment.
string $cid Content ID of the attachment. Use this to identify the Id for accessing the image in an HTML form.
string $name Overrides the attachment name.
string $encoding File encoding (see $Encoding).
string $type File extension (MIME) type.

Return Value

bool

at line 1840
bool InlineImageExists()

Returns true if an inline attachment is present.

Return Value

bool

at line 1857
void ClearAddresses()

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

Return Value

void

at line 1868
void ClearCCs()

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

Return Value

void

at line 1879
void ClearBCCs()

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

Return Value

void

at line 1890
void ClearReplyTos()

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

Return Value

void

at line 1899
void ClearAllRecipients()

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

Return Value

void

at line 1911
void ClearAttachments()

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

Return Value

void

at line 1919
void ClearCustomHeaders()

Clears all custom headers. Returns void.

Return Value

void

at line 1949
static string RFCDate()

Returns the proper RFC 822 formatted date.

Return Value

string

at line 1998
bool IsError()

Returns true if an error occurred.

Return Value

bool

at line 2019
void AddCustomHeader($custom_header)

Adds a custom header.

Parameters

$custom_header

Return Value

void

at line 2028
$message MsgHTML($message, $basedir = '')

Evaluates the message and returns modifications for inline images and backgrounds

Parameters

$message
$basedir

Return Value

$message

at line 2066
static string _mime_types(string $ext = '')

Gets the MIME type of the embedded or inline image

Parameters

string $ext File extension

Return Value

string MIME type of ext

at line 2171
set(string $name, mixed $value = '')

Set (or reset) Class Objects (variables)

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

Parameters

string $name Parameter Name
mixed $value Parameter Value NOTE: will not work with arrays, there are no arrays to set/reset

at line 2193
string SecureHeader(string $str)

Strips newlines to prevent header injection.

Parameters

string $str String

Return Value

string

at line 2206
Sign($cert_filename, $key_filename, $key_pass)

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

Parameters

$cert_filename
$key_filename
$key_pass

at line 2219
DKIM_QP($txt)

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

Parameters

$txt

at line 2239
DKIM_Sign(string $s)

Generate DKIM signature

Parameters

string $s Header

at line 2257
DKIM_HeaderC(string $s)

Generate DKIM Canonicalization Header

Parameters

string $s Header

at line 2276
DKIM_BodyC(string $body)

Generate DKIM Canonicalization Body

Parameters

string $body Message Body

at line 2296
DKIM_Add(string $headers_line, string $subject, string $body)

Create the DKIM header, body, as new header

Parameters

string $headers_line Header lines
string $subject Subject
string $body Body