[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-includes/ -> class-phpmailer.php (summary)

PHPMailer - PHP email creation and transport class. PHP Version 5

Author: Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
Author: Jim Jagielski (jimjag) <jimjag@gmail.com>
Author: Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
Author: Brent R. Matzelle (original founder)
Copyright: 2012 - 2014 Marcus Bointon
Copyright: 2010 - 2012 Jim Jagielski
Copyright: 2004 - 2009 Andy Prevost
License: http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
File Size: 4040 lines (147 kb)
Included or required: 1 time
Referenced: 0 times
Includes or requires: 1 file
 wp-includes/class-smtp.php

Defines 2 classes

PHPMailer:: (103 methods):
  __construct()
  __destruct()
  mailPassthru()
  edebug()
  isHTML()
  isSMTP()
  isMail()
  isSendmail()
  isQmail()
  addAddress()
  addCC()
  addBCC()
  addReplyTo()
  addOrEnqueueAnAddress()
  addAnAddress()
  parseAddresses()
  setFrom()
  getLastMessageID()
  validateAddress()
  idnSupported()
  punyencodeAddress()
  send()
  preSend()
  postSend()
  sendmailSend()
  isShellSafe()
  mailSend()
  getSMTPInstance()
  smtpSend()
  smtpConnect()
  smtpClose()
  setLanguage()
  getTranslations()
  addrAppend()
  addrFormat()
  wrapText()
  utf8CharBoundary()
  setWordWrap()
  createHeader()
  getMailMIME()
  getSentMIMEMessage()
  generateId()
  createBody()
  getBoundary()
  endBoundary()
  setMessageType()
  headerLine()
  textLine()
  addAttachment()
  getAttachments()
  attachAll()
  encodeFile()
  encodeString()
  encodeHeader()
  hasMultiBytes()
  has8bitChars()
  base64EncodeWrapMB()
  encodeQP()
  encodeQPphp()
  encodeQ()
  addStringAttachment()
  addEmbeddedImage()
  addStringEmbeddedImage()
  inlineImageExists()
  attachmentExists()
  alternativeExists()
  clearQueuedAddresses()
  clearAddresses()
  clearCCs()
  clearBCCs()
  clearReplyTos()
  clearAllRecipients()
  clearAttachments()
  clearCustomHeaders()
  setError()
  rfcDate()
  serverHostname()
  lang()
  isError()
  fixEOL()
  addCustomHeader()
  getCustomHeaders()
  msgHTML()
  html2text()
  _mime_types()
  filenameToType()
  mb_pathinfo()
  set()
  secureHeader()
  normalizeBreaks()
  sign()
  DKIM_QP()
  DKIM_Sign()
  DKIM_HeaderC()
  DKIM_BodyC()
  DKIM_Add()
  hasLineLongerThanMax()
  getToAddresses()
  getCcAddresses()
  getBccAddresses()
  getReplyToAddresses()
  getAllRecipientAddresses()
  doCallback()

phpmailerException:: (1 method):
  errorMessage()


Class: PHPMailer  - X-Ref

PHPMailer - PHP email creation and transport class.

__construct($exceptions = null)   X-Ref
Constructor.

param: boolean $exceptions Should we throw external exceptions?

__destruct()   X-Ref
Destructor.


mailPassthru($to, $subject, $body, $header, $params)   X-Ref
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)

param: string $to To
param: string $subject Subject
param: string $body Message Body
param: string $header Additional Header(s)
param: string $params Params
return: boolean

edebug($str)   X-Ref
Output debugging info via user-defined method.
Only generates output if SMTP debug output is enabled (@see SMTP::$do_debug).

param: string $str

isHTML($isHtml = true)   X-Ref
Sets message type to HTML or plain.

param: boolean $isHtml True for HTML mode.
return: void

isSMTP()   X-Ref
Send messages using SMTP.

return: void

isMail()   X-Ref
Send messages using PHP's mail() function.

return: void

isSendmail()   X-Ref
Send messages using $Sendmail.

return: void

isQmail()   X-Ref
Send messages using qmail.

return: void

addAddress($address, $name = '')   X-Ref
Add a "To" address.

param: string $address The email address to send to
param: string $name
return: boolean true on success, false if address already used or invalid in some way

addCC($address, $name = '')   X-Ref
Add a "CC" address.

param: string $address The email address to send to
param: string $name
return: boolean true on success, false if address already used or invalid in some way

addBCC($address, $name = '')   X-Ref
Add a "BCC" address.

param: string $address The email address to send to
param: string $name
return: boolean true on success, false if address already used or invalid in some way

addReplyTo($address, $name = '')   X-Ref
Add a "Reply-To" address.

param: string $address The email address to reply to
param: string $name
return: boolean true on success, false if address already used or invalid in some way

addOrEnqueueAnAddress($kind, $address, $name)   X-Ref
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.

param: string $kind One of 'to', 'cc', 'bcc', or 'ReplyTo'
param: string $address The email address to send, resp. to reply to
param: string $name
return: boolean true on success, false if address already used or invalid in some way

addAnAddress($kind, $address, $name = '')   X-Ref
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.

param: string $kind One of 'to', 'cc', 'bcc', or 'ReplyTo'
param: string $address The email address to send, resp. to reply to
param: string $name
return: boolean true on success, false if address already used or invalid in some way

parseAddresses($addrstr, $useimap = true)   X-Ref
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.

param: string $addrstr The address list string
param: bool $useimap Whether to use the IMAP extension to parse the list
return: array

setFrom($address, $name = '', $auto = true)   X-Ref
Set the From and FromName properties.

param: string $address
param: string $name
param: boolean $auto Whether to also set the Sender address, defaults to true
return: boolean

getLastMessageID()   X-Ref
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: string

validateAddress($address, $patternselect = null)   X-Ref
Check that a string looks like an email address.

param: string $address The email address to check
param: string|callable $patternselect A selector for the validation pattern to use :
return: boolean

idnSupported()   X-Ref
Tells whether IDNs (Internationalized Domain Names) are supported or not. This requires the
"intl" and "mbstring" PHP extensions.

return: bool "true" if required functions for IDN support are present

punyencodeAddress($address)   X-Ref
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)

param: string $address The email address to convert
return: string The encoded address in ASCII form

send()   X-Ref
Create a message and send it.
Uses the sending method specified by $Mailer.

return: boolean false on error - See the ErrorInfo property for details of the error.

preSend()   X-Ref
Prepare a message for sending.

return: boolean

postSend()   X-Ref
Actually send a message.
Send the email via the selected mechanism

return: boolean

sendmailSend($header, $body)   X-Ref
Send mail using the $Sendmail program.

param: string $header The message headers
param: string $body The message body
return: boolean

isShellSafe($string)   X-Ref
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.
param: string $string The string to be validated
return: boolean

mailSend($header, $body)   X-Ref
Send mail using the PHP mail() function.

param: string $header The message headers
param: string $body The message body
return: boolean

getSMTPInstance()   X-Ref
Get an instance to use for SMTP operations.
Override this function to load your own SMTP implementation

return: SMTP

smtpSend($header, $body)   X-Ref
Send mail via SMTP.
Returns false if there is a bad MAIL FROM, RCPT, or DATA input.
Uses the PHPMailerSMTP class by default.

param: string $header The message headers
param: string $body The message body
return: boolean

smtpConnect($options = null)   X-Ref
Initiate a connection to an SMTP server.
Returns false if the operation failed.

param: array $options An array of options compatible with stream_context_create()
return: boolean

smtpClose()   X-Ref
Close the active SMTP session if one exists.

return: void

setLanguage($langcode = 'en', $lang_path = '')   X-Ref
Set the language for error messages.
Returns false if it cannot load the language file.
The default language is English.

param: string $langcode ISO 639-1 2-character language code (e.g. French is "fr")
param: string $lang_path Path to the language file directory, with trailing separator (slash)
return: boolean

getTranslations()   X-Ref
Get the array of strings for the current language.

return: array

addrAppend($type, $addr)   X-Ref
Create recipient headers.

param: string $type
param: array $addr An array of recipient,
return: string

addrFormat($addr)   X-Ref
Format an address for use in a message header.

param: array $addr A 2-element indexed array, element 0 containing an address, element 1 containing a name
return: string

wrapText($message, $length, $qp_mode = false)   X-Ref
Word-wrap message.
For use with mailers that do not automatically perform wrapping
and for quoted-printable encoded messages.
Original written by philippe.

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

utf8CharBoundary($encodedText, $maxLength)   X-Ref
Find the last character boundary prior to $maxLength in a utf-8
quoted-printable encoded string.
Original written by Colin Brown.

param: string $encodedText utf-8 QP text
param: integer $maxLength Find the last character boundary prior to this length
return: integer

setWordWrap()   X-Ref
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.

return: void

createHeader()   X-Ref
Assemble message headers.

return: string The assembled headers

getMailMIME()   X-Ref
Get the message MIME type headers.

return: string

getSentMIMEMessage()   X-Ref
Returns the whole MIME message.
Includes complete headers and body.
Only valid post preSend().

return: string

generateId()   X-Ref
Create unique ID

return: string

createBody()   X-Ref
Assemble the message body.
Returns an empty string on failure.

return: string The assembled message body

getBoundary($boundary, $charSet, $contentType, $encoding)   X-Ref
Return the start of a message boundary.

param: string $boundary
param: string $charSet
param: string $contentType
param: string $encoding
return: string

endBoundary($boundary)   X-Ref
Return the end of a message boundary.

param: string $boundary
return: string

setMessageType()   X-Ref
Set the message type.
PHPMailer only supports some preset message types, not arbitrary MIME structures.

return: void

headerLine($name, $value)   X-Ref
Format a header line.

param: string $name
param: string $value
return: string

textLine($value)   X-Ref
Return a formatted mail line.

param: string $value
return: string

addAttachment($path, $name = '', $encoding = 'base64', $type = '', $disposition = 'attachment')   X-Ref
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.

param: string $path Path to the attachment.
param: string $name Overrides the attachment name.
param: string $encoding File encoding (see $Encoding).
param: string $type File extension (MIME) type.
param: string $disposition Disposition to use
return: boolean

getAttachments()   X-Ref
Return the array of attachments.

return: array

attachAll($disposition_type, $boundary)   X-Ref
Attach all file, string, and binary attachments to the message.
Returns an empty string on failure.

param: string $disposition_type
param: string $boundary
return: string

encodeFile($path, $encoding = 'base64')   X-Ref
Encode a file attachment in requested format.
Returns an empty string on failure.

param: string $path The full path to the file
param: string $encoding The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable'
return: string

encodeString($str, $encoding = 'base64')   X-Ref
Encode a string in requested format.
Returns an empty string on failure.

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

encodeHeader($str, $position = 'text')   X-Ref
Encode a header string optimally.
Picks shortest of Q, B, quoted-printable or none.

param: string $str
param: string $position
return: string

hasMultiBytes($str)   X-Ref
Check if a string contains multi-byte characters.

param: string $str multi-byte text to wrap encode
return: boolean

has8bitChars($text)   X-Ref
Does a string contain any 8-bit chars (in any charset)?

param: string $text
return: boolean

base64EncodeWrapMB($str, $linebreak = null)   X-Ref
Encode and wrap long multibyte strings for mail headers
without breaking lines within a character.
Adapted from a function by paravoid

param: string $str multi-byte text to wrap encode
param: string $linebreak string to use as linefeed/end-of-line
return: string

encodeQP($string, $line_max = 76)   X-Ref
Encode a string in quoted-printable format.
According to RFC2045 section 6.7.

param: string $string The text to encode
param: integer $line_max Number of chars allowed on a line before wrapping
return: string

encodeQPphp($string,$line_max = 76,$space_conv = false)   X-Ref
Backward compatibility wrapper for an old QP encoding function that was removed.

param: string $string
param: integer $line_max
param: boolean $space_conv
return: string

encodeQ($str, $position = 'text')   X-Ref
Encode a string using Q encoding.

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

addStringAttachment($string,$filename,$encoding = 'base64',$type = '',$disposition = 'attachment')   X-Ref
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.

param: string $string String attachment data.
param: string $filename Name of the attachment.
param: string $encoding File encoding (see $Encoding).
param: string $type File extension (MIME) type.
param: string $disposition Disposition to use
return: void

addEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = '', $disposition = 'inline')   X-Ref
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!

param: string $path Path to the attachment.
param: string $cid Content ID of the attachment; Use this to reference
param: string $name Overrides the attachment name.
param: string $encoding File encoding (see $Encoding).
param: string $type File MIME type.
param: string $disposition Disposition to use
return: boolean True on successfully adding an attachment

addStringEmbeddedImage($string,$cid,$name = '',$encoding = 'base64',$type = '',$disposition = 'inline')   X-Ref
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'.

param: string $string The attachment binary data.
param: string $cid Content ID of the attachment; Use this to reference
param: string $name
param: string $encoding File encoding (see $Encoding).
param: string $type MIME type.
param: string $disposition Disposition to use
return: boolean True on successfully adding an attachment

inlineImageExists()   X-Ref
Check if an inline attachment is present.

return: boolean

attachmentExists()   X-Ref
Check if an attachment (non-inline) is present.

return: boolean

alternativeExists()   X-Ref
Check if this message has an alternative body set.

return: boolean

clearQueuedAddresses($kind)   X-Ref
Clear queued addresses of given kind.

param: string $kind 'to', 'cc', or 'bcc'
return: void

clearAddresses()   X-Ref
Clear all To recipients.

return: void

clearCCs()   X-Ref
Clear all CC recipients.

return: void

clearBCCs()   X-Ref
Clear all BCC recipients.

return: void

clearReplyTos()   X-Ref
Clear all ReplyTo recipients.

return: void

clearAllRecipients()   X-Ref
Clear all recipient types.

return: void

clearAttachments()   X-Ref
Clear all filesystem, string, and binary attachments.

return: void

clearCustomHeaders()   X-Ref
Clear all custom headers.

return: void

setError($msg)   X-Ref
Add an error message to the error container.

param: string $msg
return: void

rfcDate()   X-Ref
Return an RFC 822 formatted date.

return: string

serverHostname()   X-Ref
Get the server hostname.
Returns 'localhost.localdomain' if unknown.

return: string

lang($key)   X-Ref
Get an error message in the current language.

param: string $key
return: string

isError()   X-Ref
Check if an error occurred.

return: boolean True if an error did occur.

fixEOL($str)   X-Ref
Ensure consistent line endings in a string.
Changes every end of line from CRLF, CR or LF to $this->LE.

param: string $str String to fixEOL
return: string

addCustomHeader($name, $value = null)   X-Ref
Add a custom header.
$name value can be overloaded to contain
both header name and value (name:value)

param: string $name Custom header name
param: string $value Header value
return: void

getCustomHeaders()   X-Ref
Returns all custom headers.

return: array

msgHTML($message, $basedir = '', $advanced = false)   X-Ref
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. <img src="/images/a.png"> 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.

param: string $message HTML message string
param: string $basedir Absolute path to a base directory to prepend to relative paths to images
param: boolean|callable $advanced Whether to use the internal HTML to text converter
return: string $message The transformed message Body

html2text($html, $advanced = false)   X-Ref
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:
<code>
// Use default conversion
$plain = $mail->html2text($html);
// Use your own custom converter
$plain = $mail->html2text($html, function($html) {
$converter = new MyHtml2text($html);
return $converter->get_text();
});
</code>

param: string $html The HTML text to convert
param: boolean|callable $advanced Any boolean value to use the internal converter,
return: string

_mime_types($ext = '')   X-Ref
Get the MIME type for a file extension.

param: string $ext File extension
return: string MIME type of file.

filenameToType($filename)   X-Ref
Map a file name to a MIME type.
Defaults to 'application/octet-stream', i.e.. arbitrary binary data.

param: string $filename A file name or full path, does not need to exist as a file
return: string

mb_pathinfo($path, $options = null)   X-Ref
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

param: string $path A filename or path, does not need to exist as a file
param: integer|string $options Either a PATHINFO_* constant,
return: string|array

set($name, $value = '')   X-Ref
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';`

param: string $name The property name to set
param: mixed $value The value to set the property to
return: boolean

secureHeader($str)   X-Ref
Strip newlines to prevent header injection.

param: string $str
return: string

normalizeBreaks($text, $breaktype = "\r\n")   X-Ref
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.

param: string $text
param: string $breaktype What kind of line break to use, defaults to CRLF
return: string

sign($cert_filename, $key_filename, $key_pass, $extracerts_filename = '')   X-Ref
Set the public and private key files and password for S/MIME signing.

param: string $cert_filename
param: string $key_filename
param: string $key_pass Password for private key
param: string $extracerts_filename Optional path to chain certificate

DKIM_QP($txt)   X-Ref
Quoted-Printable-encode a DKIM header.

param: string $txt
return: string

DKIM_Sign($signHeader)   X-Ref
Generate a DKIM signature.

param: string $signHeader
return: string The DKIM signature value

DKIM_HeaderC($signHeader)   X-Ref
Generate a DKIM canonicalization header.

param: string $signHeader Header
return: string

DKIM_BodyC($body)   X-Ref
Generate a DKIM canonicalization body.

param: string $body Message Body
return: string

DKIM_Add($headers_line, $subject, $body)   X-Ref
Create the DKIM header and body in a new message header.

param: string $headers_line Header lines
param: string $subject Subject
param: string $body Body
return: string

hasLineLongerThanMax($str)   X-Ref
Detect if a string contains a line longer than the maximum line length allowed.

param: string $str
return: boolean

getToAddresses()   X-Ref
Allows for public read access to 'to' property.

return: array

getCcAddresses()   X-Ref
Allows for public read access to 'cc' property.

return: array

getBccAddresses()   X-Ref
Allows for public read access to 'bcc' property.

return: array

getReplyToAddresses()   X-Ref
Allows for public read access to 'ReplyTo' property.

return: array

getAllRecipientAddresses()   X-Ref
Allows for public read access to 'all_recipients' property.

return: array

doCallback($isSent, $to, $cc, $bcc, $subject, $body, $from)   X-Ref
Perform a callback.

param: boolean $isSent
param: array $to
param: array $cc
param: array $bcc
param: string $subject
param: string $body
param: string $from

Class: phpmailerException  - X-Ref

PHPMailer exception handler

errorMessage()   X-Ref
Prettify error message output

return: string



Generated: Mon Jul 22 01:00:03 2019 Cross-referenced by PHPXref 0.7.1