[ 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: 4062 lines (148 kb)
Included or required: 1 time
Referenced: 0 times
Includes or requires: 1 file
 wp-includes/class-smtp.php

Defines 2 classes

PHPMailer:: (104 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()
  isPermittedPath()
  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)

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

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.

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

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.

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

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

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

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

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

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

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

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.

return: boolean true on success, false if address already used or invalid in some way
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

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.

return: boolean true on success, false if address already used or invalid in some way
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

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.

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

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

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

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.

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

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)

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

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.

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

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.
return: boolean
param: string $string The string to be validated

isPermittedPath($path)   X-Ref
Check whether a file path is of a permitted type.
Used to reject URLs and phar files from functions that access local file paths,
such as addAttachment.

return: bool
param: string $path A relative or absolute path to a file.

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

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

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.

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

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

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

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.

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

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

return: array

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

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

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

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

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.

return: string
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

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.

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

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.

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

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

return: string
param: string $boundary

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.

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

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

return: string
param: string $value

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.
Explicitly *does not* support passing URLs; PHPMailer is not an HTTP client.
If you need to do that, fetch the resource yourself and pass it in via a local file or string.

return: boolean
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

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.

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

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

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

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

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

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

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

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

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

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

return: boolean
param: string $text

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

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

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

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

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

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

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

return: string
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

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.

return: void
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

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!

return: boolean True on successfully adding an attachment
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

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

return: boolean True on successfully adding an attachment
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

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.

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

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.

return: void
param: string $msg

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.

return: string
param: string $key

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.

return: string
param: string $str String to fixEOL

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

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

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.

return: string $message The transformed message Body
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

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>

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

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

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

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

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

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

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

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';`

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

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

return: string
param: string $str

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.

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

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.

return: string
param: string $txt

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

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

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

return: string
param: string $signHeader Header

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

return: string
param: string $body Message Body

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

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

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

return: boolean
param: string $str

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: Thu Sep 19 01:00:03 2019 Cross-referenced by PHPXref 0.7.1