\PHPMailer

Summary

Methods
Properties
Constants
__construct()
IsHTML()
IsSMTP()
IsMail()
IsSendmail()
IsQmail()
AddAddress()
AddCC()
AddBCC()
AddReplyTo()
SetFrom()
ValidateAddress()
Send()
SmtpConnect()
SmtpClose()
SetLanguage()
GetTranslations()
AddrAppend()
AddrFormat()
WrapText()
UTF8CharBoundary()
SetWordWrap()
CreateHeader()
GetMailMIME()
CreateBody()
HeaderLine()
TextLine()
AddAttachment()
GetAttachments()
EncodeString()
EncodeHeader()
HasMultiBytes()
Base64EncodeWrapMB()
EncodeQPphp()
EncodeQP()
EncodeQ()
AddStringAttachment()
AddEmbeddedImage()
AddStringEmbeddedImage()
InlineImageExists()
AttachmentExists()
AlternativeExists()
ClearAddresses()
ClearCCs()
ClearBCCs()
ClearReplyTos()
ClearAllRecipients()
ClearAttachments()
ClearCustomHeaders()
RFCDate()
IsError()
FixEOL()
AddCustomHeader()
MsgHTML()
_mime_types()
set()
SecureHeader()
Sign()
DKIM_QP()
DKIM_Sign()
DKIM_HeaderC()
DKIM_BodyC()
DKIM_Add()
$Priority
$CharSet
$ContentType
$Encoding
$ErrorInfo
$From
$FromName
$Sender
$Subject
$Body
$AltBody
$WordWrap
$Mailer
$Sendmail
$PluginDir
$ConfirmReadingTo
$Hostname
$MessageID
$Host
$Port
$Helo
$SMTPSecure
$SMTPAuth
$Username
$Password
$Timeout
$SMTPDebug
$SMTPKeepAlive
$SingleTo
$SingleToArray
$LE
$DKIM_selector
$DKIM_identity
$DKIM_passphrase
$DKIM_domain
$DKIM_private
$action_function
$Version
$XMailer
STOP_MESSAGE
STOP_CONTINUE
STOP_CRITICAL
AddAnAddress()
PreSend()
PostSend()
SendmailSend()
MailSend()
SmtpSend()
GetBoundary()
EndBoundary()
SetMessageType()
AttachAll()
EncodeFile()
SetError()
ServerHostname()
Lang()
doCallback()
$MIMEBody
$MIMEHeader
$smtp
$to
$cc
$bcc
$ReplyTo
$all_recipients
$attachment
$CustomHeader
$message_type
$boundary
$language
$error_count
$sign_cert_file
$sign_key_file
$sign_key_pass
$exceptions
N/A
No private methods found
No private properties found
N/A

Constants

STOP_MESSAGE

STOP_MESSAGE

STOP_CONTINUE

STOP_CONTINUE

STOP_CRITICAL

STOP_CRITICAL

Properties

$Priority

$Priority : integer

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

Type

integer

$CharSet

$CharSet : string

Sets the CharSet of the message.

Type

string

$ContentType

$ContentType : string

Sets the Content-type of the message.

Type

string

$Encoding

$Encoding : string

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

Type

string

$ErrorInfo

$ErrorInfo : string

Holds the most recent mailer error message.

Type

string

$From

$From : string

Sets the From email address for the message.

Type

string

$FromName

$FromName : string

Sets the From name of the message.

Type

string

$Sender

$Sender : string

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.

Type

string

$Subject

$Subject : string

Sets the Subject of the message.

Type

string

$Body

$Body : string

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

If HTML then run IsHTML(true).

Type

string

$AltBody

$AltBody : string

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.

Type

string

$WordWrap

$WordWrap : integer

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

Type

integer

$Mailer

$Mailer : string

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

Type

string

$Sendmail

$Sendmail : string

Sets the path of the sendmail program.

Type

string

$PluginDir

$PluginDir : string

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

Type

string

$ConfirmReadingTo

$ConfirmReadingTo : string

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

Type

string

$Hostname

$Hostname : string

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

Type

string

$MessageID

$MessageID : string

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

If empty, a unique id will be generated.

Type

string

$Host

$Host : string

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

Hosts will be tried in order.

Type

string

$Port

$Port : integer

Sets the default SMTP server port.

Type

integer

$Helo

$Helo : string

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

Type

string

$SMTPSecure

$SMTPSecure : string

Sets connection prefix.

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

Type

string

$SMTPAuth

$SMTPAuth : boolean

Sets SMTP authentication. Utilizes the Username and Password variables.

Type

boolean

$Username

$Username : string

Sets SMTP username.

Type

string

$Password

$Password : string

Sets SMTP password.

Type

string

$Timeout

$Timeout : integer

Sets the SMTP server timeout in seconds.

This function will not work with the win32 version.

Type

integer

$SMTPDebug

$SMTPDebug : boolean

Sets SMTP class debugging on or off.

Type

boolean

$SMTPKeepAlive

$SMTPKeepAlive : boolean

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().

Type

boolean

$SingleTo

$SingleTo : boolean

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

Type

boolean

$SingleToArray

$SingleToArray : boolean

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

Type

boolean

$LE

$LE : string

Provides the ability to change the line ending

Type

string

$DKIM_selector

$DKIM_selector : string

Used with DKIM DNS Resource Record

Type

string

$DKIM_identity

$DKIM_identity : string

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

Type

string

$DKIM_passphrase

$DKIM_passphrase : string

Used with DKIM DNS Resource Record

Type

string

$DKIM_domain

$DKIM_domain : string

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

Type

string

$DKIM_private

$DKIM_private : string

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

Type

string

$action_function

$action_function : string

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

Type

string

$Version

$Version : string

Sets the PHPMailer Version number

Type

string

$XMailer

$XMailer : string

What to use in the X-Mailer header

Type

string

$MIMEBody

$MIMEBody : string

Stores the complete compiled MIME message body.

Type

string

$MIMEHeader

$MIMEHeader : string

Stores the complete compiled MIME message headers.

Type

string

$smtp

$smtp : 

Type

$to

$to : 

Type

$cc

$cc : 

Type

$bcc

$bcc : 

Type

$ReplyTo

$ReplyTo : 

Type

$all_recipients

$all_recipients : 

Type

$attachment

$attachment : 

Type

$CustomHeader

$CustomHeader : 

Type

$message_type

$message_type : 

Type

$boundary

$boundary : 

Type

$language

$language : 

Type

$error_count

$error_count : 

Type

$sign_cert_file

$sign_cert_file : 

Type

$sign_key_file

$sign_key_file : 

Type

$sign_key_pass

$sign_key_pass : 

Type

$exceptions

$exceptions : 

Type

Methods

__construct()

__construct(boolean  $exceptions = false) 

Constructor

Parameters

boolean $exceptions

Should we throw external exceptions?

IsHTML()

IsHTML(boolean  $ishtml = true) : void

Sets message type to HTML.

Parameters

boolean $ishtml

IsSMTP()

IsSMTP() : void

Sets Mailer to send message using SMTP.

IsMail()

IsMail() : void

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

IsSendmail()

IsSendmail() : void

Sets Mailer to send message using the $Sendmail program.

IsQmail()

IsQmail() : void

Sets Mailer to send message using the qmail MTA.

AddAddress()

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

Adds a "To" address.

Parameters

string $address
string $name

Returns

boolean —

true on success, false if address already used

AddCC()

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

Adds a "Cc" address.

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

Parameters

string $address
string $name

Returns

boolean —

true on success, false if address already used

AddBCC()

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

Adds a "Bcc" address.

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

Parameters

string $address
string $name

Returns

boolean —

true on success, false if address already used

AddReplyTo()

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

Adds a "Reply-to" address.

Parameters

string $address
string $name

Returns

boolean

SetFrom()

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

Set the From and FromName properties

Parameters

string $address
string $name
$auto

Returns

boolean

ValidateAddress()

ValidateAddress(string  $address) : boolean

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

Returns

boolean

Send()

Send() : boolean

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.

Returns

boolean

SmtpConnect()

SmtpConnect() : boolean

Initiates a connection to an SMTP server.

Returns false if the operation failed.

Returns

boolean

SmtpClose()

SmtpClose() : void

Closes the active SMTP session if one exists.

SetLanguage()

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

GetTranslations()

GetTranslations() : array

Return the current array of language strings

Returns

array

AddrAppend()

AddrAppend(  $type,   $addr) : string

Creates recipient headers.

Parameters

$type
$addr

Returns

string

AddrFormat()

AddrFormat(  $addr) : string

Formats an address correctly.

Parameters

$addr

Returns

string

WrapText()

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

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

Returns

string

UTF8CharBoundary()

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

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

integer $maxLength

find last character boundary prior to this length

Returns

integer

SetWordWrap()

SetWordWrap() : void

Set the body wrapping.

CreateHeader()

CreateHeader() : string

Assembles message header.

Returns

string —

The assembled header

GetMailMIME()

GetMailMIME() : string

Returns the message MIME.

Returns

string

CreateBody()

CreateBody() : string

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

Returns

string —

The assembled message body

HeaderLine()

HeaderLine(  $name,   $value) : string

Returns a formatted header line.

Parameters

$name
$value

Returns

string

TextLine()

TextLine(  $value) : string

Returns a formatted mail line.

Parameters

$value

Returns

string

AddAttachment()

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

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.

Returns

boolean

GetAttachments()

GetAttachments() : array

Return the current array of attachments

Returns

array

EncodeString()

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

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'

Returns

string

EncodeHeader()

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

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

Parameters

$str
$position

Returns

string

HasMultiBytes()

HasMultiBytes(string  $str) : boolean

Checks if a string contains multibyte characters.

Parameters

string $str

multi-byte text to wrap encode

Returns

boolean

Base64EncodeWrapMB()

Base64EncodeWrapMB(string  $str) : string

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

Returns

string

EncodeQPphp()

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

Encode string to quoted-printable.

Only uses standard PHP, slow, but will always work

Parameters

$input
integer $line_max

Number of chars allowed on a line before wrapping

$space_conv

Returns

string

EncodeQP()

EncodeQP(string  $string, integer  $line_max = 76, boolean  $space_conv = false) : 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

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

Returns

string

EncodeQ()

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

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

Returns

string

AddStringAttachment()

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

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.

AddEmbeddedImage()

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

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.

Returns

boolean

AddStringEmbeddedImage()

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

Parameters

$string
$cid
$filename
$encoding
$type

InlineImageExists()

InlineImageExists() : boolean

Returns true if an inline attachment is present.

Returns

boolean

AttachmentExists()

AttachmentExists() 

AlternativeExists()

AlternativeExists() 

ClearAddresses()

ClearAddresses() : void

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

ClearCCs()

ClearCCs() : void

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

ClearBCCs()

ClearBCCs() : void

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

ClearReplyTos()

ClearReplyTos() : void

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

ClearAllRecipients()

ClearAllRecipients() : void

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

ClearAttachments()

ClearAttachments() : void

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

ClearCustomHeaders()

ClearCustomHeaders() : void

Clears all custom headers. Returns void.

RFCDate()

RFCDate() : string

Returns the proper RFC 822 formatted date.

Returns

string

IsError()

IsError() : boolean

Returns true if an error occurred.

Returns

boolean

FixEOL()

FixEOL(  $str) : string

Changes every end of line from CR or LF to CRLF.

Parameters

$str

Returns

string

AddCustomHeader()

AddCustomHeader(  $custom_header) : void

Adds a custom header.

Parameters

$custom_header

MsgHTML()

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

Evaluates the message and returns modifications for inline images and backgrounds

Parameters

$message
$basedir

Returns

\$message

_mime_types()

_mime_types(  $ext = '') : string

Gets the MIME type of the embedded or inline image

Parameters

$ext

Returns

string —

MIME type of ext

set()

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

SecureHeader()

SecureHeader(string  $str) : string

Strips newlines to prevent header injection.

Parameters

string $str

String

Returns

string

Sign()

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

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

Parameters

$cert_filename
string $key_filename

Parameter File Name

string $key_pass

Password for private key

DKIM_QP()

DKIM_QP(  $txt) 

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

Parameters

$txt

DKIM_Sign()

DKIM_Sign(string  $s) 

Generate DKIM signature

Parameters

string $s

Header

DKIM_HeaderC()

DKIM_HeaderC(string  $s) 

Generate DKIM Canonicalization Header

Parameters

string $s

Header

DKIM_BodyC()

DKIM_BodyC(string  $body) 

Generate DKIM Canonicalization Body

Parameters

string $body

Message Body

DKIM_Add()

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

AddAnAddress()

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

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

Parameters

string $kind

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

string $address

The email address to send to

string $name

Returns

boolean —

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

PreSend()

PreSend() 

PostSend()

PostSend() 

SendmailSend()

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

Sends mail using the $Sendmail program.

Parameters

string $header

The message headers

string $body

The message body

Returns

boolean

MailSend()

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

Sends mail using the PHP mail() function.

Parameters

string $header

The message headers

string $body

The message body

Returns

boolean

SmtpSend()

SmtpSend(string  $header, string  $body) : boolean

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

Parameters

string $header

The message headers

string $body

The message body

Returns

boolean

GetBoundary()

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

Returns the start of a message boundary.

Parameters

$boundary
$charSet
$contentType
$encoding

Returns

string

EndBoundary()

EndBoundary(  $boundary) : string

Returns the end of a message boundary.

Parameters

$boundary

Returns

string

SetMessageType()

SetMessageType() : void

Sets the message type.

AttachAll()

AttachAll(  $disposition_type,   $boundary) : string

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

Returns an empty string on failure.

Parameters

$disposition_type
$boundary

Returns

string

EncodeFile()

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

Encodes attachment in requested format.

Returns an empty string on failure.

Parameters

string $path

The full path to the file

string $encoding

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

Returns

string

SetError()

SetError(  $msg) : void

Adds the error message to the error container.

Parameters

$msg

ServerHostname()

ServerHostname() : string

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

Returns

string

Lang()

Lang(  $key) : string

Returns a message in the appropriate language.

Parameters

$key

Returns

string

doCallback()

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

Parameters

$isSent
$to
$cc
$bcc
$subject
$body