Methods summary
public |
# __construct( boolean
$exceptions = null )
Constructor.
Parameters
- $exceptions
- Should we throw external exceptions?
|
public |
|
private boolean |
# mailPassthru( string
$to, string $subject,
string $body, string
$header, string $params
)
Call mail() in a safe_mode-aware fashion. Also, unless
sendmail_path points to sendmail (or something that claims to be
sendmail), don't pass params (not a perfect fix, but it will
do)
Call mail() in a safe_mode-aware fashion. Also, unless
sendmail_path points to sendmail (or something that claims to be
sendmail), don't pass params (not a perfect fix, but it will
do)
Parameters
- $to
- To
- $subject
- Subject
- $body
- Message Body
- $header
- Additional Header(s)
- $params
- Params
Returns
boolean
|
protected |
# edebug( string
$str )
Output debugging info via user-defined method. Only generates
output if SMTP debug output is enabled (@see SMTP::$do_debug).
Output debugging info via user-defined method. Only generates
output if SMTP debug output is enabled (@see SMTP::$do_debug).
Parameters
See
|
public |
# isHTML( boolean
$isHtml = true
)
Sets message type to HTML or plain.
Sets message type to HTML or plain.
Parameters
- $isHtml
- True for HTML mode.
|
public |
# isSMTP( )
Send messages using SMTP.
Send messages using SMTP.
|
public |
# isMail( )
Send messages using PHP's mail() function.
Send messages using PHP's mail() function.
|
public |
# isSendmail( )
Send messages using $Sendmail.
Send messages using $Sendmail.
|
public |
# isQmail( )
Send messages using qmail.
Send messages using qmail.
|
public boolean |
# addAddress( string
$address, string $name =
'' )
Add a "To" address.
Parameters
- $address
- The email address to send to
- $name
Returns
boolean
true on success, false if address already used or invalid in some
way
|
public boolean |
# addCC( string
$address, string $name =
'' )
Add a "CC" address.
Parameters
- $address
- The email address to send to
- $name
Returns
boolean
true on success, false if address already used or invalid in some
way
Note:
This function works with the SMTP mailer on
win32, not with the "mail" mailer.
|
public boolean |
# addBCC( string
$address, string $name =
'' )
Add a "BCC" address.
Parameters
- $address
- The email address to send to
- $name
Returns
boolean
true on success, false if address already used or invalid in some
way
Note:
This function works with the SMTP mailer on
win32, not with the "mail" mailer.
|
public boolean |
# addReplyTo( string
$address, string $name =
'' )
Add a "Reply-To" address.
Add a "Reply-To" address.
Parameters
- $address
- The email address to reply to
- $name
Returns
boolean
true on success, false if address already used or invalid in some
way
|
protected boolean |
#
addOrEnqueueAnAddress( string
$kind, string $address,
string $name )
Add an address to one of the recipient arrays or to the ReplyTo
array. Because PHPMailer can't validate addresses with an IDN
without knowing the PHPMailer::$CharSet (that can still be modified
after calling this function), addition of such addresses is delayed
until send(). Addresses that have been added already return false,
but do not throw exceptions.
Add an address to one of the recipient arrays or to the ReplyTo
array. Because PHPMailer can't validate addresses with an IDN
without knowing the PHPMailer::$CharSet (that can still be modified
after calling this function), addition of such addresses is delayed
until send(). Addresses that have been added already return false,
but do not throw exceptions.
Parameters
- $kind
- One of 'to', 'cc', 'bcc', or 'ReplyTo'
- $address
- The email address to send, resp. to reply to
- $name
Returns
boolean
true on success, false if address already used or invalid in some
way
Throws
|
protected boolean |
# addAnAddress( string
$kind, string $address,
string $name = '' )
Add an address to one of the recipient arrays or to the ReplyTo
array. Addresses that have been added already return false, but do
not throw exceptions.
Add an address to one of the recipient arrays or to the ReplyTo
array. Addresses that have been added already return false, but do
not throw exceptions.
Parameters
- $kind
- One of 'to', 'cc', 'bcc', or 'ReplyTo'
- $address
- The email address to send, resp. to reply to
- $name
Returns
boolean
true on success, false if address already used or invalid in some
way
Throws
|
public array |
# parseAddresses( string
$addrstr, boolean $useimap =
true )
Parse and validate a string containing one or more RFC822-style
comma-separated email addresses of the form "display name
<
address>" into an array of name/address pairs. Uses the
imap_rfc822_parse_adrlist function if the IMAP extension is
available. Note that quotes in the name part are removed.
Parse and validate a string containing one or more RFC822-style
comma-separated email addresses of the form "display name
<
address>" into an array of name/address pairs. Uses the
imap_rfc822_parse_adrlist function if the IMAP extension is
available. Note that quotes in the name part are removed.
Parameters
- $addrstr
- The address list string
- $useimap
- Whether to use the IMAP extension to parse the list
Returns
array
Link
|
public boolean |
# setFrom( string
$address, string $name =
'', boolean
$auto = true
)
Set the From and FromName properties.
Set the From and FromName properties.
Parameters
- $address
- $name
- $auto
- Whether to also set the Sender address, defaults to true
Returns
boolean
Throws
|
public string |
#
getLastMessageID( )
Return the Message-ID header of the last email. Technically this
is the value from the last time the headers were created, but it's
also the message ID of the last sent message except in pathological
cases.
Return the Message-ID header of the last email. Technically this
is the value from the last time the headers were created, but it's
also the message ID of the last sent message except in pathological
cases.
Returns
string
|
public static boolean |
#
validateAddress( string
$address, string|callable
$patternselect = null )
Check that a string looks like an email address.
Check that a string looks like an email address.
Parameters
- $address
- The email address to check
- $patternselect
-
A selector for the validation pattern to use : *
auto Pick best pattern automatically; *
pcre8 Use the squiloople.com pattern, requires PCRE
> 8.0, PHP >= 5.3.2, 5.2.14; * pcre Use old PCRE
implementation; * php Use PHP built-in
FILTER_VALIDATE_EMAIL; * html5 Use the pattern given
by the HTML5 spec for 'email' type form input elements. *
noregex Don't use a regex: super fast, really dumb.
Alternatively you may pass in a callable to inject your own
validator, for example:
PHPMailer::validateAddress('user@example.com', function($address) {
return (strpos($address, '@') !== false); }); You can also set the
PHPMailer::$validator static to a callable, allowing built-in
methods to use your validator.
Returns
boolean
|
public boolean |
# idnSupported( )
Tells whether IDNs (Internationalized Domain Names) are
supported or not. This requires the "intl" and "mbstring" PHP
extensions.
Tells whether IDNs (Internationalized Domain Names) are
supported or not. This requires the "intl" and "mbstring" PHP
extensions.
Returns
boolean
"true" if required functions for IDN support are present
|
public string |
#
punyencodeAddress( string
$address )
Converts IDN in given email address to its ASCII form, also
known as punycode, if possible. Important: Address must be passed
in same encoding as currently set in PHPMailer::$CharSet. This
function silently returns unmodified address if: - No conversion is
necessary (i.e. domain name is not an IDN, or is already in ASCII
form) - Conversion to punycode is impossible (e.g. required PHP
functions are not available) or fails for any reason (e.g. domain
has characters not allowed in an IDN)
Converts IDN in given email address to its ASCII form, also
known as punycode, if possible. Important: Address must be passed
in same encoding as currently set in PHPMailer::$CharSet. This
function silently returns unmodified address if: - No conversion is
necessary (i.e. domain name is not an IDN, or is already in ASCII
form) - Conversion to punycode is impossible (e.g. required PHP
functions are not available) or fails for any reason (e.g. domain
has characters not allowed in an IDN)
Parameters
- $address
- The email address to convert
Returns
string
The encoded address in ASCII form
See
|
public boolean |
# send( )
Create a message and send it. Uses the sending method specified
by $Mailer.
Create a message and send it. Uses the sending method specified
by $Mailer.
Returns
boolean
false on error - See the ErrorInfo property for details of the
error.
Throws
|
public boolean |
# preSend( )
Prepare a message for sending.
Prepare a message for sending.
Returns
boolean
Throws
|
public boolean |
# postSend( )
Actually send a message. Send the email via the selected
mechanism
Actually send a message. Send the email via the selected
mechanism
Returns
boolean
Throws
|
protected boolean |
# sendmailSend( string
$header, string $body
)
Send mail using the $Sendmail program.
Send mail using the $Sendmail program.
Parameters
- $header
- The message headers
- $body
- The message body
Returns
boolean
Throws
See
|
protected static boolean |
# isShellSafe( string
$string )
Fix CVE-2016-10033 and CVE-2016-10045 by disallowing potentially
unsafe shell characters.
Fix CVE-2016-10033 and CVE-2016-10045 by disallowing potentially
unsafe shell characters.
Note that escapeshellarg and escapeshellcmd are inadequate for
our purposes, especially on Windows.
Parameters
- $string
- The string to be validated
Returns
boolean
See
https://github.com/PHPMailer/PHPMailer/issues/924
CVE-2016-10045 bug report
|
protected boolean |
# mailSend( string
$header, string $body
)
Send mail using the PHP mail() function.
Send mail using the PHP mail() function.
Parameters
- $header
- The message headers
- $body
- The message body
Returns
boolean
Throws
Link
|
public SMTP |
#
getSMTPInstance( )
Get an instance to use for SMTP operations. Override this
function to load your own SMTP implementation
Get an instance to use for SMTP operations. Override this
function to load your own SMTP implementation
Returns
|
protected boolean |
# smtpSend( string
$header, string $body
)
Send mail via SMTP. Returns false if there is a bad MAIL FROM,
RCPT, or DATA input. Uses the PHPMailerSMTP class by default.
Send mail via SMTP. Returns false if there is a bad MAIL FROM,
RCPT, or DATA input. Uses the PHPMailerSMTP class by default.
Parameters
- $header
- The message headers
- $body
- The message body
Returns
boolean
Throws
See
PHPMailer::getSMTPInstance() to use a different
class.
Uses
|
public boolean |
# smtpConnect( array
$options = null
)
Initiate a connection to an SMTP server. Returns false if the
operation failed.
Initiate a connection to an SMTP server. Returns false if the
operation failed.
Parameters
- $options
- An array of options compatible with
stream_context_create()
Returns
boolean
Throws
Uses
|
public |
# smtpClose( )
Close the active SMTP session if one exists.
Close the active SMTP session if one exists.
|
public boolean |
# setLanguage( string
$langcode = 'en',
string $lang_path = '' )
Set the language for error messages. Returns false if it cannot
load the language file. The default language is English.
Set the language for error messages. Returns false if it cannot
load the language file. The default language is English.
Parameters
- $langcode
- ISO 639-1 2-character language code (e.g. French is "fr")
- $lang_path
- Path to the language file directory, with trailing separator
(slash)
Returns
boolean
|
public array |
#
getTranslations( )
Get the array of strings for the current language.
Get the array of strings for the current language.
Returns
array
|
public string |
# addrAppend( string
$type, array $addr
)
Create recipient headers.
Create recipient headers.
Parameters
- $type
- $addr
-
An array of recipient, where each recipient is a 2-element
indexed array with element 0 containing an address and element 1
containing a name, like: array(array('joe@example.com', 'Joe
User'), array('zoe@example.com', 'Zoe User'))
Returns
string
|
public string |
# addrFormat( array
$addr )
Format an address for use in a message header.
Format an address for use in a message header.
Parameters
- $addr
-
A 2-element indexed array, element 0 containing an address,
element 1 containing a name like array('joe@example.com', 'Joe
User')
Returns
string
|
public string |
# wrapText( string
$message, integer
$length, boolean $qp_mode =
false )
Word-wrap message. For use with mailers that do not
automatically perform wrapping and for quoted-printable encoded
messages. Original written by philippe.
Word-wrap message. For use with mailers that do not
automatically perform wrapping and for quoted-printable encoded
messages. Original written by philippe.
Parameters
- $message
- The message to wrap
- $length
- The line length to wrap to
- $qp_mode
- Whether to run in Quoted-Printable mode
Returns
string
|
public integer |
#
utf8CharBoundary( string
$encodedText, integer
$maxLength )
Find the last character boundary prior to $maxLength in a utf-8
quoted-printable encoded string. Original written by Colin
Brown.
Find the last character boundary prior to $maxLength in a utf-8
quoted-printable encoded string. Original written by Colin
Brown.
Parameters
- $encodedText
- utf-8 QP text
- $maxLength
- Find the last character boundary prior to this length
Returns
integer
|
public |
# setWordWrap( )
Apply word wrapping to the message body. Wraps the message body
to the number of chars set in the WordWrap property. You should
only do this to plain-text bodies as wrapping HTML tags may break
them. This is called automatically by createBody(), so you don't
need to call it yourself.
Apply word wrapping to the message body. Wraps the message body
to the number of chars set in the WordWrap property. You should
only do this to plain-text bodies as wrapping HTML tags may break
them. This is called automatically by createBody(), so you don't
need to call it yourself.
|
public string |
# getMailMIME( )
Get the message MIME type headers.
Get the message MIME type headers.
Returns
string
|
public string |
#
getSentMIMEMessage( )
Returns the whole MIME message. Includes complete headers and
body. Only valid post preSend().
Returns the whole MIME message. Includes complete headers and
body. Only valid post preSend().
Returns
string
See
|
protected string |
|
public string |
# createBody( )
Assemble the message body. Returns an empty string on
failure.
Assemble the message body. Returns an empty string on
failure.
Returns
string
The assembled message body
Throws
|
protected string |
# getBoundary( string
$boundary, string
$charSet, string
$contentType, string
$encoding )
Return the start of a message boundary.
Return the start of a message boundary.
Parameters
- $boundary
- $charSet
- $contentType
- $encoding
Returns
string
|
protected string |
# endBoundary( string
$boundary )
Return the end of a message boundary.
Return the end of a message boundary.
Parameters
Returns
string
|
protected |
# setMessageType( )
Set the message type. PHPMailer only supports some preset
message types, not arbitrary MIME structures.
Set the message type. PHPMailer only supports some preset
message types, not arbitrary MIME structures.
|
public string |
# textLine( string
$value )
Return a formatted mail line.
Return a formatted mail line.
Parameters
Returns
string
|
public boolean |
# addAttachment( string
$path, string $name =
'', string
$encoding = 'base64', string $type =
'', string
$disposition = 'attachment' )
Add an attachment from a path on the filesystem. Never use a
user-supplied path to a file! Returns false if the file could not
be found or read.
Add an attachment from a path on the filesystem. Never use a
user-supplied path to a file! Returns false if the file could not
be found or read.
Parameters
- $path
- Path to the attachment.
- $name
- Overrides the attachment name.
- $encoding
- File encoding (see $Encoding).
- $type
- File extension (MIME) type.
- $disposition
- Disposition to use
Returns
boolean
Throws
|
public array |
# getAttachments( )
Return the array of attachments.
Return the array of attachments.
Returns
array
|
protected string |
# attachAll( string
$disposition_type, string
$boundary )
Attach all file, string, and binary attachments to the message.
Returns an empty string on failure.
Attach all file, string, and binary attachments to the message.
Returns an empty string on failure.
Parameters
- $disposition_type
- $boundary
Returns
string
|
protected string |
# encodeFile( string
$path, string $encoding =
'base64' )
Encode a file attachment in requested format. Returns an empty
string on failure.
Encode a file attachment in requested format. Returns an empty
string on failure.
Parameters
- $path
- The full path to the file
- $encoding
- The encoding to use; one of 'base64', '7bit', '8bit', 'binary',
'quoted-printable'
Returns
string
Throws
|
public string |
# encodeString( string
$str, string $encoding =
'base64' )
Encode a string in requested format. Returns an empty string on
failure.
Encode a string in requested format. Returns an empty string on
failure.
Parameters
- $str
- The text to encode
- $encoding
- The encoding to use; one of 'base64', '7bit', '8bit', 'binary',
'quoted-printable'
Returns
string
|
public boolean |
# hasMultiBytes( string
$str )
Check if a string contains multi-byte characters.
Check if a string contains multi-byte characters.
Parameters
- $str
- multi-byte text to wrap encode
Returns
boolean
|
public boolean |
# has8bitChars( string
$text )
Does a string contain any 8-bit chars (in any charset)?
Does a string contain any 8-bit chars (in any charset)?
Parameters
Returns
boolean
|
public string |
#
base64EncodeWrapMB( string
$str, string $linebreak =
null )
Encode and wrap long multibyte strings for mail headers without
breaking lines within a character. Adapted from a function by
paravoid
Encode and wrap long multibyte strings for mail headers without
breaking lines within a character. Adapted from a function by
paravoid
Parameters
- $str
- multi-byte text to wrap encode
- $linebreak
- string to use as linefeed/end-of-line
Returns
string
Link
|
public string |
# encodeQP( string
$string, integer $line_max =
76 )
Encode a string in quoted-printable format. According to RFC2045
section 6.7.
Encode a string in quoted-printable format. According to RFC2045
section 6.7.
Parameters
- $string
- The text to encode
- $line_max
- Number of chars allowed on a line before wrapping
Returns
string
Link
|
public string |
# encodeQPphp( string
$string, integer $line_max =
76, boolean
$space_conv = false )
Backward compatibility wrapper for an old QP encoding function
that was removed.
Backward compatibility wrapper for an old QP encoding function
that was removed.
Deprecated
Use encodeQP instead.
Parameters
- $string
- $line_max
- $space_conv
Returns
string
See
|
public string |
# encodeQ( string
$str, string $position =
'text' )
Encode a string using Q encoding.
Encode a string using Q encoding.
Parameters
- $str
- the text to encode
- $position
- Where the text is going to be used, see the RFC for what that
means
Returns
string
Link
|
public |
#
addStringAttachment( string
$string, string
$filename, string $encoding =
'base64', string
$type = '',
string $disposition = 'attachment' )
Add a string or binary attachment (non-filesystem). This method
can be used to attach ascii or binary data, such as a BLOB record
from a database.
Add a string or binary attachment (non-filesystem). This method
can be used to attach ascii or binary data, such as a BLOB record
from a database.
Parameters
- $string
- String attachment data.
- $filename
- Name of the attachment.
- $encoding
- File encoding (see $Encoding).
- $type
- File extension (MIME) type.
- $disposition
- Disposition to use
|
public boolean |
#
addEmbeddedImage( string
$path, string $cid,
string $name = '', string $encoding =
'base64', string
$type = '',
string $disposition = 'inline' )
Add an embedded (inline) attachment from a file. This can
include images, sounds, and just about any other document type.
These differ from 'regular' attachments in that they are intended
to be displayed inline with the message, not just attached for
download. This is used in HTML messages that embed the images the
HTML refers to using the $cid value. Never use a user-supplied path
to a file!
Add an embedded (inline) attachment from a file. This can
include images, sounds, and just about any other document type.
These differ from 'regular' attachments in that they are intended
to be displayed inline with the message, not just attached for
download. This is used in HTML messages that embed the images the
HTML refers to using the $cid value. Never use a user-supplied path
to a file!
Parameters
- $path
- Path to the attachment.
- $cid
-
Content ID of the attachment; Use this to reference the content
when using an embedded image in HTML.
- $name
- Overrides the attachment name.
- $encoding
- File encoding (see $Encoding).
- $type
- File MIME type.
- $disposition
- Disposition to use
Returns
boolean
True on successfully adding an attachment
|
public boolean |
#
addStringEmbeddedImage( string
$string, string $cid,
string $name = '', string $encoding =
'base64', string
$type = '',
string $disposition = 'inline' )
Add an embedded stringified attachment. This can include images,
sounds, and just about any other document type. Be sure to set the
$type to an image type for images: JPEG images use 'image/jpeg',
GIF uses 'image/gif', PNG uses 'image/png'.
Add an embedded stringified attachment. This can include images,
sounds, and just about any other document type. Be sure to set the
$type to an image type for images: JPEG images use 'image/jpeg',
GIF uses 'image/gif', PNG uses 'image/png'.
Parameters
- $string
- The attachment binary data.
- $cid
-
Content ID of the attachment; Use this to reference the content
when using an embedded image in HTML.
- $name
- $encoding
- File encoding (see $Encoding).
- $type
- MIME type.
- $disposition
- Disposition to use
Returns
boolean
True on successfully adding an attachment
|
public boolean |
#
inlineImageExists( )
Check if an inline attachment is present.
Check if an inline attachment is present.
Returns
boolean
|
public boolean |
#
attachmentExists( )
Check if an attachment (non-inline) is present.
Check if an attachment (non-inline) is present.
Returns
boolean
|
public boolean |
#
alternativeExists( )
Check if this message has an alternative body set.
Check if this message has an alternative body set.
Returns
boolean
|
public |
#
clearQueuedAddresses( string
$kind )
Clear queued addresses of given kind.
Clear queued addresses of given kind.
Parameters
- $kind
- 'to', 'cc', or 'bcc'
|
public |
|
public |
|
public |
# clearBCCs( )
Clear all BCC recipients.
Clear all BCC recipients.
|
public |
# clearReplyTos( )
Clear all ReplyTo recipients.
Clear all ReplyTo recipients.
|
public |
|
public |
#
clearAttachments( )
Clear all filesystem, string, and binary attachments.
Clear all filesystem, string, and binary attachments.
|
protected |
# setError( string
$msg )
Add an error message to the error container.
Add an error message to the error container.
Parameters
|
public static string |
# rfcDate( )
Return an RFC 822 formatted date.
Return an RFC 822 formatted date.
Returns
string
|
protected string |
# serverHostname( )
Get the server hostname. Returns 'localhost.localdomain' if
unknown.
Get the server hostname. Returns 'localhost.localdomain' if
unknown.
Returns
string
|
protected string |
# lang( string
$key )
Get an error message in the current language.
Get an error message in the current language.
Parameters
Returns
string
|
public boolean |
# isError( )
Check if an error occurred.
Check if an error occurred.
Returns
boolean
True if an error did occur.
|
public string |
# fixEOL( string
$str )
Ensure consistent line endings in a string. Changes every end of
line from CRLF, CR or LF to $this->LE.
Ensure consistent line endings in a string. Changes every end of
line from CRLF, CR or LF to $this->LE.
Parameters
Returns
string
|
public string |
# msgHTML( string
$message, string $basedir =
'', boolean|callable
$advanced = false )
Create a message body from an HTML string. Automatically inlines
images and creates a plain-text version by converting the HTML,
overwriting any existing values in Body and AltBody. Do not source
$message content from user input! $basedir is prepended when
handling relative URLs, e.g. and must not be empty will look
for an image file in $basedir/images/a.png and convert it to
inline. If you don't provide a $basedir, relative paths will be
left untouched (and thus probably break in email) If you don't want
to apply these transformations to your HTML, just set Body and
AltBody directly.
Create a message body from an HTML string. Automatically inlines
images and creates a plain-text version by converting the HTML,
overwriting any existing values in Body and AltBody. Do not source
$message content from user input! $basedir is prepended when
handling relative URLs, e.g. and must not be empty will look
for an image file in $basedir/images/a.png and convert it to
inline. If you don't provide a $basedir, relative paths will be
left untouched (and thus probably break in email) If you don't want
to apply these transformations to your HTML, just set Body and
AltBody directly.
Parameters
- $message
- HTML message string
- $basedir
- Absolute path to a base directory to prepend to relative paths
to images
- $advanced
-
Whether to use the internal HTML to text converter or your own
custom converter @see PHPMailer::html2text()
Returns
string
$message The transformed message Body
|
public string |
# html2text( string
$html, boolean|callable
$advanced = false )
Convert an HTML string into plain text. This is used by
msgHTML(). Note - older versions of this function used a bundled
advanced converter which was been removed for license reasons in
#232. Example usage:
$plain = $mail->html2text($html);
$plain = $mail->html2text($html, function($html) {
$converter = new MyHtml2text($html);
return $converter->get_text();
});
Convert an HTML string into plain text. This is used by
msgHTML(). Note - older versions of this function used a bundled
advanced converter which was been removed for license reasons in
#232. Example usage:
$plain = $mail->html2text($html);
$plain = $mail->html2text($html, function($html) {
$converter = new MyHtml2text($html);
return $converter->get_text();
});
Parameters
- $html
- The HTML text to convert
- $advanced
-
Any boolean value to use the internal converter, or provide your
own callable for custom conversion.
Returns
string
|
public static string |
# _mime_types( string
$ext = '' )
Get the MIME type for a file extension.
Get the MIME type for a file extension.
Parameters
Returns
string
MIME type of file.
|
public static string |
# filenameToType( string
$filename )
Map a file name to a MIME type. Defaults to
'application/octet-stream', i.e.. arbitrary binary data.
Map a file name to a MIME type. Defaults to
'application/octet-stream', i.e.. arbitrary binary data.
Parameters
- $filename
- A file name or full path, does not need to exist as a file
Returns
string
|
public static string|array |
# mb_pathinfo( string
$path, integer|string $options =
null )
Multi-byte-safe pathinfo replacement. Drop-in replacement for
pathinfo(), but multibyte-safe, cross-platform-safe,
old-version-safe. Works similarly to the one in PHP >= 5.2.0
Multi-byte-safe pathinfo replacement. Drop-in replacement for
pathinfo(), but multibyte-safe, cross-platform-safe,
old-version-safe. Works similarly to the one in PHP >= 5.2.0
Parameters
- $path
- A filename or path, does not need to exist as a file
- $options
-
Either a PATHINFO_* constant, or a string name to return only
the specified piece, allows 'filename' to work on PHP < 5.2
Returns
string|array
Link
|
public boolean |
# set( string
$name, mixed $value =
'' )
Set or reset instance properties. You should avoid this function
- it's more verbose, less efficient, more error-prone and harder to
debug than setting properties directly. Usage Example:
$mail->set('SMTPSecure', 'tls'); is the same as:
$mail->SMTPSecure = 'tls';
Set or reset instance properties. You should avoid this function
- it's more verbose, less efficient, more error-prone and harder to
debug than setting properties directly. Usage Example:
$mail->set('SMTPSecure', 'tls'); is the same as:
$mail->SMTPSecure = 'tls';
Parameters
- $name
- The property name to set
- $value
- The value to set the property to
Returns
boolean
|
public static string |
#
normalizeBreaks( string
$text, string $breaktype =
"\r\n" )
Normalize line breaks in a string. Converts UNIX LF, Mac CR and
Windows CRLF line breaks into a single line break format. Defaults
to CRLF (for message bodies) and preserves consecutive breaks.
Normalize line breaks in a string. Converts UNIX LF, Mac CR and
Windows CRLF line breaks into a single line break format. Defaults
to CRLF (for message bodies) and preserves consecutive breaks.
Parameters
- $text
- $breaktype
- What kind of line break to use, defaults to CRLF
Returns
string
|
public |
# sign( string
$cert_filename, string
$key_filename, string
$key_pass, string
$extracerts_filename = '' )
Set the public and private key files and password for S/MIME
signing.
Set the public and private key files and password for S/MIME
signing.
Parameters
- $cert_filename
- $key_filename
- $key_pass
- Password for private key
- $extracerts_filename
- Optional path to chain certificate
|
public string |
# DKIM_QP( string
$txt )
Quoted-Printable-encode a DKIM header.
Quoted-Printable-encode a DKIM header.
Parameters
Returns
string
|
public string |
# DKIM_Sign( string
$signHeader )
Generate a DKIM signature.
Generate a DKIM signature.
Parameters
Returns
string
The DKIM signature value
Throws
|
public string |
# DKIM_BodyC( string
$body )
Generate a DKIM canonicalization body.
Generate a DKIM canonicalization body.
Parameters
Returns
string
|
public string |
# DKIM_Add( string
$headers_line, string
$subject, string $body
)
Create the DKIM header and body in a new message header.
Create the DKIM header and body in a new message header.
Parameters
- $headers_line
- Header lines
- $subject
- Subject
- $body
- Body
Returns
string
|
public static boolean |
#
hasLineLongerThanMax( string
$str )
Detect if a string contains a line longer than the maximum line
length allowed.
Detect if a string contains a line longer than the maximum line
length allowed.
Parameters
Returns
boolean
|
public array |
# getToAddresses( )
Allows for public read access to 'to' property.
Allows for public read access to 'to' property.
Returns
array
Note:
Before the send() call, queued addresses (i.e.
with IDN) are not yet included.
|
public array |
# getCcAddresses( )
Allows for public read access to 'cc' property.
Allows for public read access to 'cc' property.
Returns
array
Note:
Before the send() call, queued addresses (i.e.
with IDN) are not yet included.
|
public array |
#
getBccAddresses( )
Allows for public read access to 'bcc' property.
Allows for public read access to 'bcc' property.
Returns
array
Note:
Before the send() call, queued addresses (i.e.
with IDN) are not yet included.
|
public array |
#
getReplyToAddresses( )
Allows for public read access to 'ReplyTo' property.
Allows for public read access to 'ReplyTo' property.
Returns
array
Note:
Before the send() call, queued addresses (i.e.
with IDN) are not yet included.
|
public array |
#
getAllRecipientAddresses( )
Allows for public read access to 'all_recipients' property.
Allows for public read access to 'all_recipients' property.
Returns
array
Note:
Before the send() call, queued addresses (i.e.
with IDN) are not yet included.
|
protected |
# doCallback( boolean
$isSent, array $to,
array $cc, array
$bcc, string $subject,
string $body, string
$from )
Perform a callback.
Parameters
- $isSent
- $to
- $cc
- $bcc
- $subject
- $body
- $from
|
Properties summary
public string |
$Version
The PHPMailer Version number.
The PHPMailer Version number.
|
|
public integer |
$Priority
Email priority. Options: null (default), 1 = High, 3 = Normal, 5
= low. When null, the header is not set at all.
Email priority. Options: null (default), 1 = High, 3 = Normal, 5
= low. When null, the header is not set at all.
|
|
public string |
$CharSet
The character set of the message.
The character set of the message.
|
|
public string |
$ContentType
The MIME Content-type of the message.
The MIME Content-type of the message.
|
|
public string |
$Encoding
The message encoding. Options: "8bit", "7bit", "binary",
"base64", and "quoted-printable".
The message encoding. Options: "8bit", "7bit", "binary",
"base64", and "quoted-printable".
|
|
public string |
$ErrorInfo
Holds the most recent mailer error message.
Holds the most recent mailer error message.
|
|
public string |
$From
The From email address for the message.
The From email address for the message.
|
|
public string |
$FromName
The From name of the message.
The From name of the message.
|
|
public string |
$Sender
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.
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.
|
|
public string |
$ReturnPath
The Return-Path of the message. If empty, it will be set to
either From or Sender.
The Return-Path of the message. If empty, it will be set to
either From or Sender.
Deprecated
Email senders should never set a return-path header; it's the
receiver's job (RFC5321 section 4.4), so this no longer does
anything.
Link
|
|
public string |
$Subject
The Subject of the message.
The Subject of the message.
|
|
public string |
$Body
An HTML or plain text message body. If HTML then call
isHTML(true).
An HTML or plain text message body. If HTML then call
isHTML(true).
|
|
public string |
$AltBody
The plain-text message body. This body can be read by mail
clients that do not have HTML email capability such as mutt &
Eudora. Clients that can read HTML will view the normal Body.
The plain-text message body. This body can be read by mail
clients that do not have HTML email capability such as mutt &
Eudora. Clients that can read HTML will view the normal Body.
|
|
public string |
$Ical
An iCal message part body. Only supported in simple alt or
alt_inline message types To generate iCal events, use the bundled
extras/EasyPeasyICS.php class or iCalcreator
An iCal message part body. Only supported in simple alt or
alt_inline message types To generate iCal events, use the bundled
extras/EasyPeasyICS.php class or iCalcreator
Link
|
|
protected string |
$MIMEBody
The complete compiled MIME message body.
The complete compiled MIME message body.
|
|
public integer |
$WordWrap
Word-wrap the message body to this number of chars. Set to 0 to
not wrap. A useful value here is 78, for RFC2822 section 2.1.1
compliance.
Word-wrap the message body to this number of chars. Set to 0 to
not wrap. A useful value here is 78, for RFC2822 section 2.1.1
compliance.
|
|
public string |
$Mailer
Which method to use to send mail. Options: "mail", "sendmail",
or "smtp".
Which method to use to send mail. Options: "mail", "sendmail",
or "smtp".
|
|
public string |
$Sendmail
The path to the sendmail program.
The path to the sendmail program.
|
|
public boolean |
$UseSendmailOptions
Whether mail() uses a fully sendmail-compatible MTA. One which
supports sendmail's "-oi -f" options.
Whether mail() uses a fully sendmail-compatible MTA. One which
supports sendmail's "-oi -f" options.
|
|
public string |
$PluginDir
Path to PHPMailer plugins. Useful if the SMTP class is not in
the PHP include path.
Path to PHPMailer plugins. Useful if the SMTP class is not in
the PHP include path.
Deprecated
Should not be needed now there is an
autoloader.
|
|
public string |
$ConfirmReadingTo
The email address that a reading confirmation should be sent to,
also known as read receipt.
The email address that a reading confirmation should be sent to,
also known as read receipt.
|
|
public string |
$Hostname
The hostname to use in the Message-ID header and as default HELO
string. If empty, PHPMailer attempts to find one with, in order,
$_SERVER['SERVER_NAME'], gethostname(), php_uname('n'), or the
value 'localhost.localdomain'.
The hostname to use in the Message-ID header and as default HELO
string. If empty, PHPMailer attempts to find one with, in order,
$_SERVER['SERVER_NAME'], gethostname(), php_uname('n'), or the
value 'localhost.localdomain'.
|
|
public string |
$MessageID
An ID to be used in the Message-ID header. If empty, a unique id
will be generated. You can set your own, but it must be in the
format "<id@domain>", as defined in RFC5322 section 3.6.4 or
it will be ignored.
An ID to be used in the Message-ID header. If empty, a unique id
will be generated. You can set your own, but it must be in the
format "<id@domain>", as defined in RFC5322 section 3.6.4 or
it will be ignored.
See
https://tools.ietf.org/html/rfc5322#section-3.6.4
|
|
public string |
$MessageDate
The message Date to be used in the Date header. If empty, the
current date will be added.
The message Date to be used in the Date header. If empty, the
current date will be added.
|
|
public string |
$Host
SMTP hosts. Either a single hostname or multiple
semicolon-delimited hostnames. 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"). You can also specify
encryption type, for example: (e.g.
"tls://smtp1.example.com:587;ssl://smtp2.example.com:465"). Hosts
will be tried in order.
SMTP hosts. Either a single hostname or multiple
semicolon-delimited hostnames. 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"). You can also specify
encryption type, for example: (e.g.
"tls://smtp1.example.com:587;ssl://smtp2.example.com:465"). Hosts
will be tried in order.
|
|
public integer |
$Port
The default SMTP server port.
The default SMTP server port.
|
|
public string |
$Helo
The SMTP HELO of the message. Default is $Hostname. If $Hostname
is empty, PHPMailer attempts to find one with the same method
described above for $Hostname.
The SMTP HELO of the message. Default is $Hostname. If $Hostname
is empty, PHPMailer attempts to find one with the same method
described above for $Hostname.
See
|
|
public string |
$SMTPSecure
What kind of encryption to use on the SMTP connection. Options:
'', 'ssl' or 'tls'
What kind of encryption to use on the SMTP connection. Options:
'', 'ssl' or 'tls'
|
|
public boolean |
$SMTPAutoTLS
Whether to enable TLS encryption automatically if a server
supports it, even if SMTPSecure is not set to 'tls'.
Be aware that in PHP >= 5.6 this requires that the server's
certificates are valid.
Whether to enable TLS encryption automatically if a server
supports it, even if SMTPSecure is not set to 'tls'.
Be aware that in PHP >= 5.6 this requires that the server's
certificates are valid.
|
|
public boolean |
$SMTPAuth
Whether to use SMTP authentication. Uses the Username and
Password properties.
Whether to use SMTP authentication. Uses the Username and
Password properties.
See
|
|
public array |
$SMTPOptions
Options array passed to stream_context_create when connecting
via SMTP.
Options array passed to stream_context_create when connecting
via SMTP.
|
|
public string |
$Username
|
|
public string |
$Password
|
|
public string |
$AuthType
SMTP auth type. Options are CRAM-MD5, LOGIN, PLAIN, NTLM,
XOAUTH2, attempted in that order if not specified
SMTP auth type. Options are CRAM-MD5, LOGIN, PLAIN, NTLM,
XOAUTH2, attempted in that order if not specified
|
|
public string |
$Realm
SMTP realm. Used for NTLM auth
SMTP realm. Used for NTLM auth
|
|
public string |
$Workstation
SMTP workstation. Used for NTLM auth
SMTP workstation. Used for NTLM auth
|
|
public integer |
$Timeout
The SMTP server timeout in seconds. Default of 5 minutes
(300sec) is from RFC2821 section 4.5.3.2
The SMTP server timeout in seconds. Default of 5 minutes
(300sec) is from RFC2821 section 4.5.3.2
|
|
public integer |
$SMTPDebug
SMTP class debug output mode. Debug output level. Options: *
0 No output * 1 Commands * 2
Data and commands * 3 As 2 plus connection status *
4 Low-level data output
SMTP class debug output mode. Debug output level. Options: *
0 No output * 1 Commands * 2
Data and commands * 3 As 2 plus connection status *
4 Low-level data output
See
|
|
public string|callable |
$Debugoutput
How to handle debug output. Options: * echo Output
plain-text as-is, appropriate for CLI * html Output
escaped, line breaks converted to <br> ,
appropriate for browser output * error_log Output to
error log as configured in php.ini
How to handle debug output. Options: * echo Output
plain-text as-is, appropriate for CLI * html Output
escaped, line breaks converted to <br> ,
appropriate for browser output * error_log Output to
error log as configured in php.ini
Alternatively, you can provide a callable expecting two params:
a message string and the debug level:
$mail->Debugoutput = function($str, $level) {echo "debug level $level; message: $str";};
See
|
|
public boolean |
$SMTPKeepAlive
Whether to keep SMTP connection open after each message. If this
is set to true then to close the connection requires an explicit
call to smtpClose().
Whether to keep SMTP connection open after each message. If this
is set to true then to close the connection requires an explicit
call to smtpClose().
|
|
public boolean |
$SingleTo
Whether to split multiple to addresses into multiple messages or
send them all in one message. Only supported in mail
and sendmail transports, not in SMTP.
Whether to split multiple to addresses into multiple messages or
send them all in one message. Only supported in mail
and sendmail transports, not in SMTP.
|
|
public array |
$SingleToArray
Storage for addresses when SingleTo is enabled.
Storage for addresses when SingleTo is enabled.
|
|
public boolean |
$do_verp
Whether to generate VERP addresses on send. Only applicable when
sending via SMTP.
Whether to generate VERP addresses on send. Only applicable when
sending via SMTP.
Link
|
|
public boolean |
$AllowEmpty
Whether to allow sending messages with an empty body.
Whether to allow sending messages with an empty body.
|
|
public string |
$LE
The default line ending.
Note
The default remains "\n". We force CRLF where we know it must be
used via self::CRLF.
|
|
public string |
$DKIM_selector
|
|
public string |
$DKIM_identity
DKIM Identity. Usually the email address used as the source of
the email.
DKIM Identity. Usually the email address used as the source of
the email.
|
|
public string |
$DKIM_passphrase
DKIM passphrase. Used if your key is encrypted.
DKIM passphrase. Used if your key is encrypted.
|
|
public string |
$DKIM_domain
DKIM signing domain name.
DKIM signing domain name.
Example
'example.com'
|
|
public string |
$DKIM_private
DKIM private key file path.
DKIM private key file path.
|
|
public string |
$DKIM_private_string
DKIM private key string. If set, takes precedence over
$DKIM_private .
DKIM private key string. If set, takes precedence over
$DKIM_private .
|
|
public string |
$action_function
Callback Action function name.
Callback Action function name.
The function that handles the result of the send email action.
It is called out by send() for each email sent.
Value can be any php callable:
http://www.php.net/is_callable
Parameters: boolean $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 $from email address of sender
|
|
public string |
$XMailer
What to put in the X-Mailer header. Options: An empty string for
PHPMailer default, whitespace for none, or a string to use
What to put in the X-Mailer header. Options: An empty string for
PHPMailer default, whitespace for none, or a string to use
|
|
public static
string|callable |
$validator
Which validator to use by default when validating email
addresses. May be a callable to inject your own validator, but
there are several built-in validators.
Which validator to use by default when validating email
addresses. May be a callable to inject your own validator, but
there are several built-in validators.
See
|
|
protected SMTP |
$smtp
An instance of the SMTP sender class.
An instance of the SMTP sender class.
|
|
protected array |
$to
The array of 'to' names and addresses.
The array of 'to' names and addresses.
|
|
protected array |
$cc
The array of 'cc' names and addresses.
The array of 'cc' names and addresses.
|
|
protected array |
$bcc
The array of 'bcc' names and addresses.
The array of 'bcc' names and addresses.
|
|
protected array |
$ReplyTo
The array of reply-to names and addresses.
The array of reply-to names and addresses.
|
|
protected array |
$all_recipients
An array of all kinds of addresses. Includes all of $to, $cc,
$bcc
An array of all kinds of addresses. Includes all of $to, $cc,
$bcc
See
PHPMailer::$to @see PHPMailer::$cc @see
PHPMailer::$bcc
|
|
protected array |
$RecipientsQueue
An array of names and addresses queued for validation. In
send(), valid and non duplicate entries are moved to
$all_recipients and one of $to, $cc, or $bcc. This array is used
only for addresses with IDN.
An array of names and addresses queued for validation. In
send(), valid and non duplicate entries are moved to
$all_recipients and one of $to, $cc, or $bcc. This array is used
only for addresses with IDN.
See
|
|
protected array |
$ReplyToQueue
An array of reply-to names and addresses queued for validation.
In send(), valid and non duplicate entries are moved to $ReplyTo.
This array is used only for addresses with IDN.
An array of reply-to names and addresses queued for validation.
In send(), valid and non duplicate entries are moved to $ReplyTo.
This array is used only for addresses with IDN.
See
|
|
protected array |
$attachment
The array of attachments.
The array of attachments.
|
|
protected string |
$lastMessageID
The most recent Message-ID (including angular brackets).
The most recent Message-ID (including angular brackets).
|
|
protected string |
$message_type
|
|
protected array |
$boundary
The array of MIME boundary strings.
The array of MIME boundary strings.
|
|
protected array |
$language
The array of available languages.
The array of available languages.
|
|
protected integer |
$error_count
The number of errors encountered.
The number of errors encountered.
|
|
protected string |
$sign_cert_file
The S/MIME certificate file path.
The S/MIME certificate file path.
|
|
protected string |
$sign_key_file
The S/MIME key file path.
The S/MIME key file path.
|
|
protected string |
$sign_key_pass
The S/MIME password for the key. Used only if the key is
encrypted.
The S/MIME password for the key. Used only if the key is
encrypted.
|
|
protected boolean |
$exceptions
Whether to throw exceptions for errors.
Whether to throw exceptions for errors.
|
|
protected string |
$uniqueid
Unique ID used for message ID and boundaries.
Unique ID used for message ID and boundaries.
|
|