PHPMailer
- Source
wp-includes/PHPMailer/PHPMailer.php:32
PHPMailer - PHP email creation and transport class.
Compatibility
- WordPress
- core
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0).
Properties · 79
$Priorityint|nullpublic- Email priority.
$CharSetstringpublic- The character set of the message.
$ContentTypestringpublic- The MIME Content-Type of the message.
$Encodingstringpublic- The message encoding.
$ErrorInfostringpublic- Holds the most recent mailer error message.
$Fromstringpublic- The From email address for the message.
$FromNamestringpublic- The From name of the message.
$Senderstringpublic- The envelope sender of the message.
$Subjectstringpublic- The Subject of the message.
$Bodystringpublic- An HTML or plain text message body.
$AltBodystringpublic- The plain-text message body.
$Icalstringpublic- An iCal message part body.
$IcalMethodsstring[]protected static- Value-array of "method" in Content-Type header "text/calendar"
$MIMEBodystringprotected- The complete compiled MIME message body.
$MIMEHeaderstringprotected- The complete compiled MIME message headers.
$mailHeaderstringprotected- Extra headers that createHeader() doesn't fold in.
$WordWrapintpublic- Word-wrap the message body to this number of chars.
$Mailerstringpublic- Which method to use to send mail.
$Sendmailstringpublic- The path to the sendmail program.
$UseSendmailOptionsboolpublic- Whether mail() uses a fully sendmail-compatible MTA.
$ConfirmReadingTostringpublic- The email address that a reading confirmation should be sent to, also known as read receipt.
$Hostnamestringpublic- The hostname to use in the Message-ID header and as default HELO string.
$MessageIDstringpublic- An ID to be used in the Message-ID header.
$MessageDatestringpublic- The message Date to be used in the Date header.
$Hoststringpublic- SMTP hosts.
$Portintpublic- The default SMTP server port.
$Helostringpublic- The SMTP HELO/EHLO name used for the SMTP connection.
$SMTPSecurestringpublic- What kind of encryption to use on the SMTP connection.
$SMTPAutoTLSboolpublic- Whether to enable TLS encryption automatically if a server supports it, even if
SMTPSecureis not set to 'tls'. $SMTPAuthboolpublic- Whether to use SMTP authentication.
$SMTPOptionsarraypublic- Options array passed to stream_context_create when connecting via SMTP.
$Usernamestringpublic- SMTP username.
$Passwordstringpublic- SMTP password.
$AuthTypestringpublic- SMTP authentication type. Options are CRAM-MD5, LOGIN, PLAIN, XOAUTH2.
$SMTPXClientarrayprotected- SMTP SMTPXClient command attributes
$oauthPHPMailer\PHPMailer\OAuthTokenProviderprotected- An implementation of the PHPMailer OAuthTokenProvider interface.
$Timeoutintpublic- The SMTP server timeout in seconds.
$dsnpublic- Comma separated list of DSN notifications 'NEVER' under no circumstances a DSN must be returned to the sender.
$SMTPDebugintpublic- SMTP class debug output mode.
$Debugoutputstring|callable|Psr\Log\LoggerInterfacepublic- How to handle debug output.
$SMTPKeepAliveboolpublic- Whether to keep the SMTP connection open after each message.
$SingleToboolpublic- Whether to split multiple to addresses into multiple messages or send them all in one message.
$SingleToArrayarrayprotected- Storage for addresses when SingleTo is enabled.
$do_verpboolpublic- Whether to generate VERP addresses on send.
$AllowEmptyboolpublic- Whether to allow sending messages with an empty body.
$DKIM_selectorstringpublic- DKIM selector.
$DKIM_identitystringpublic- DKIM Identity.
$DKIM_passphrasestringpublic- DKIM passphrase.
$DKIM_domainstringpublic- DKIM signing domain name.
$DKIM_copyHeaderFieldsboolpublic- DKIM Copy header field values for diagnostic use.
$DKIM_extraHeadersarraypublic- DKIM Extra signing headers.
$DKIM_privatestringpublic- DKIM private key file path.
$DKIM_private_stringstringpublic- DKIM private key string.
$action_functioncallable|PHPMailer\PHPMailer\callable-stringpublic- Callback Action function name.
$XMailerstring|nullpublic- What to put in the X-Mailer header.
$validatorstring|callablepublic static- Which validator to use by default when validating email addresses.
$smtpPHPMailer\PHPMailer\SMTPprotected- An instance of the SMTP sender class.
$toarrayprotected- The array of 'to' names and addresses.
$ccarrayprotected- The array of 'cc' names and addresses.
$bccarrayprotected- The array of 'bcc' names and addresses.
$ReplyToarrayprotected- The array of reply-to names and addresses.
$all_recipientsarrayprotected- An array of all kinds of addresses.
$RecipientsQueuearrayprotected- An array of names and addresses queued for validation.
$ReplyToQueuearrayprotected- An array of reply-to names and addresses queued for validation.
$UseSMTPUTF8boolpublic- Whether the need for SMTPUTF8 has been detected. Set by preSend() if necessary.
$attachmentarrayprotected- The array of attachments.
$CustomHeaderarrayprotected- The array of custom headers.
$lastMessageIDstringprotected- The most recent Message-ID (including angular brackets).
$message_typestringprotected- The message's MIME type.
$boundaryarrayprotected- The array of MIME boundary strings.
$languagearrayprotected static- The array of available text strings for the current language.
$error_countintprotected- The number of errors encountered.
$sign_cert_filestringprotected- The S/MIME certificate file path.
$sign_key_filestringprotected- The S/MIME key file path.
$sign_extracerts_filestringprotected- The optional S/MIME extra certificates ("CA Chain") file path.
$sign_key_passstringprotected- The S/MIME password for the key.
$exceptionsboolprotected- Whether to throw exceptions for errors.
$uniqueidstringprotected- Unique ID used for message ID and boundaries.
$LEstringprotected static- SMTP RFC standard line ending; Carriage Return, Line Feed.
Methods · 129
- __construct()Constructor.
- __destruct()Destructor.
- mailPassthru()Call mail() in a safe_mode-aware fashion.
- edebug()Output debugging info via a user-defined method.
- isHTML()Sets message type to HTML or plain.
- isSMTP()Send messages using SMTP.
- isMail()Send messages using PHP's mail() function.
- parseSendmailPath()Extract sendmail path and parse to deal with known parameters.
- isSendmail()Send messages using $Sendmail.
- isQmail()Send messages using qmail.
- addAddress()Add a "To" address.
- addCC()Add a "CC" address.
- addBCC()Add a "BCC" address.
- addReplyTo()Add a "Reply-To" address.
- addOrEnqueueAnAddress()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().
- setBoundaries()Set the boundaries to use for delimiting MIME parts.
- addAnAddress()Add an address to one of the recipient arrays or to the ReplyTo array.
- parseAddresses()Parse and validate a string containing one or more RFC822-style comma-separated email addresses of the form "display name " into an array of name/address pairs.
- parseSimplerAddresses()Parse a string containing one or more RFC822-style comma-separated email addresses with the form "display name " into an array of name/address pairs.
- parseEmailString()Parse a string containing an email address with an optional name and divide it into a name and email address.
- setFrom()Set the From and FromName properties.
- getLastMessageID()Return the Message-ID header of the last email.
- validateAddress()Check that a string looks like an email address.
- idnSupported()Tells whether IDNs (Internationalized Domain Names) are supported or not. This requires the `intl` and `mbstring` PHP extensions.
- punyencodeAddress()Converts IDN in given email address to its ASCII form, also known as punycode, if possible.
- send()Create a message and send it.
- preSend()Prepare a message for sending.
- postSend()Actually send a message via the selected mechanism.
- sendmailSend()Send mail using the $Sendmail program.
- isShellSafe()Fix CVE-2016-10033 and CVE-2016-10045 by disallowing potentially unsafe shell characters.
- isPermittedPath()Check whether a file path is of a permitted type.
- fileIsAccessible()Check whether a file path is safe, accessible, and readable.
- mailSend()Send mail using the PHP mail() function.
- getSMTPInstance()Get an instance to use for SMTP operations.
- setSMTPInstance()Provide an instance to use for SMTP operations.
- setSMTPXclientAttribute()Provide SMTP XCLIENT attributes
- getSMTPXclientAttributes()Get SMTP XCLIENT attributes
- smtpSend()Send mail via SMTP.
- smtpConnect()Initiate a connection to an SMTP server.
- smtpClose()Close the active SMTP session if one exists.
- setLanguage()Set the language for error messages.
- getTranslations()Get the array of strings for the current language.
- addrAppend()Create recipient headers.
- addrFormat()Format an address for use in a message header.
- wrapText()Word-wrap message.
- utf8CharBoundary()Find the last character boundary prior to $maxLength in a utf-8 quoted-printable encoded string.
- setWordWrap()Apply word wrapping to the message body.
- createHeader()Assemble message headers.
- getMailMIME()Get the message MIME type headers.
- getSentMIMEMessage()Returns the whole MIME message.
- generateId()Create a unique ID to use for boundaries.
- createBody()Assemble the message body.
- getBoundaries()Get the boundaries that this message will use
- getBoundary()Return the start of a message boundary.
- endBoundary()Return the end of a message boundary.
- setMessageType()Set the message type.
- headerLine()Format a header line.
- textLine()Return a formatted mail line.
- addAttachment()Add an attachment from a path on the filesystem.
- getAttachments()Return the array of attachments.
- attachAll()Attach all file, string, and binary attachments to the message.
- encodeFile()Encode a file attachment in requested format.
- encodeString()Encode a string in requested format.
- encodeHeader()Encode a header value (not including its label) optimally.
- decodeHeader()Decode an RFC2047-encoded header value Attempts multiple strategies so it works even when the mbstring extension is disabled.
- hasMultiBytes()Check if a string contains multi-byte characters.
- has8bitChars()Does a string contain any 8-bit chars (in any charset)?
- base64EncodeWrapMB()Encode and wrap long multibyte strings for mail headers without breaking lines within a character.
- encodeQP()Encode a string in quoted-printable format.
- encodeQ()Encode a string using Q encoding.
- addStringAttachment()Add a string or binary attachment (non-filesystem).
- addEmbeddedImage()Add an embedded (inline) attachment from a file.
- addStringEmbeddedImage()Add an embedded stringified attachment.
- validateEncoding()Validate encodings.
- cidExists()Check if an embedded attachment is present with this cid.
- inlineImageExists()Check if an inline attachment is present.
- attachmentExists()Check if an attachment (non-inline) is present.
- alternativeExists()Check if this message has an alternative body set.
- clearQueuedAddresses()Clear queued addresses of given kind.
- clearAddresses()Clear all To recipients.
- clearCCs()Clear all CC recipients.
- clearBCCs()Clear all BCC recipients.
- clearReplyTos()Clear all ReplyTo recipients.
- clearAllRecipients()Clear all recipient types.
- clearAttachments()Clear all filesystem, string, and binary attachments.
- clearCustomHeaders()Clear all custom headers.
- clearCustomHeader()Clear a specific custom header by name or name and value.
- replaceCustomHeader()Replace a custom header.
- setError()Add an error message to the error container.
- rfcDate()Return the current date and time as an RFC 822 formatted date.
- sanitiseDate()Normalise a user-supplied date into a correctly-formatted RFC 5322 date value string suitable for use in the Date header.
- serverHostname()Get the server hostname.
- isValidHost()Validate whether a string contains a valid value to use as a hostname or IP address.
- addressHasUnicodeLocalPart()Check whether the supplied address uses Unicode in the local part.
- anyAddressHasUnicodeLocalPart()Check whether any of the supplied addresses use Unicode in the local part.
- needsSMTPUTF8()Check whether the message requires SMTPUTF8 based on what's known so far.
- lang()Get an error message in the current language.
- getSmtpErrorMessage()Build an error message starting with a generic one and adding details if possible.
- isError()Check if an error occurred.
- addCustomHeader()Add a custom header.
- getCustomHeaders()Returns all custom headers.
- msgHTML()Create a message body from an HTML string.
- html2text()Convert an HTML string into plain text.
- _mime_types()Get the MIME type for a file extension.
- filenameToType()Map a file name to a MIME type.
- mb_pathinfo()Multi-byte-safe pathinfo replacement.
- set()Set or reset instance properties.
- secureHeader()Strip newlines to prevent header injection.
- normalizeBreaks()Normalize line breaks in a string.
- stripTrailingWSP()Remove trailing whitespace from a string.
- stripTrailingBreaks()Strip trailing line breaks from a string.
- getLE()Return the current line break format string.
- setLE()Set the line break format string, e.g. "\r\n".
- sign()Set the public and private key files and password for S/MIME signing.
- DKIM_QP()Quoted-Printable-encode a DKIM header.
- DKIM_Sign()Generate a DKIM signature.
- DKIM_HeaderC()Generate a DKIM canonicalization header.
- DKIM_BodyC()Generate a DKIM canonicalization body.
- DKIM_Add()Create the DKIM header and body in a new message header.
- hasLineLongerThanMax()Detect if a string contains a line longer than the maximum line length allowed by RFC 2822 section 2.1.1.
- quotedString()If a string contains any "special" characters, double-quote the name, and escape any double quotes with a backslash.
- getToAddresses()Allows for public read access to 'to' property.
- getCcAddresses()Allows for public read access to 'cc' property.
- getBccAddresses()Allows for public read access to 'bcc' property.
- getReplyToAddresses()Allows for public read access to 'ReplyTo' property.
- getAllRecipientAddresses()Allows for public read access to 'all_recipients' property.
- doCallback()Perform a callback.
- getOAuth()Get the OAuthTokenProvider instance.
- setOAuth()Set an OAuthTokenProvider instance.
Source code
class PHPMailer{ const CHARSET_ASCII = 'us-ascii'; const CHARSET_ISO88591 = 'iso-8859-1'; const CHARSET_UTF8 = 'utf-8'; const CONTENT_TYPE_PLAINTEXT = 'text/plain'; const CONTENT_TYPE_TEXT_CALENDAR = 'text/calendar'; const CONTENT_TYPE_TEXT_HTML = 'text/html'; const CONTENT_TYPE_MULTIPART_ALTERNATIVE = 'multipart/alternative'; const CONTENT_TYPE_MULTIPART_MIXED = 'multipart/mixed'; const CONTENT_TYPE_MULTIPART_RELATED = 'multipart/related'; const ENCODING_7BIT = '7bit'; const ENCODING_8BIT = '8bit'; const ENCODING_BASE64 = 'base64'; const ENCODING_BINARY = 'binary'; const ENCODING_QUOTED_PRINTABLE = 'quoted-printable'; const ENCRYPTION_STARTTLS = 'tls'; const ENCRYPTION_SMTPS = 'ssl'; const ICAL_METHOD_REQUEST = 'REQUEST'; const ICAL_METHOD_PUBLISH = 'PUBLISH'; const ICAL_METHOD_REPLY = 'REPLY'; const ICAL_METHOD_ADD = 'ADD'; const ICAL_METHOD_CANCEL = 'CANCEL'; const ICAL_METHOD_REFRESH = 'REFRESH'; const ICAL_METHOD_COUNTER = 'COUNTER'; const ICAL_METHOD_DECLINECOUNTER = 'DECLINECOUNTER'; const RFC822_DATE_FORMAT = 'D, j M Y H:i:s O'; /** * Email priority. * Options: null (default), 1 = High, 3 = Normal, 5 = low. * When null, the header is not set at all. * * @var int|null */ public $Priority; /** * The character set of the message. * * @var string */ public $CharSet = self::CHARSET_ISO88591; /** * The MIME Content-Type of the message. * * @var string */ public $ContentType = self::CONTENT_TYPE_PLAINTEXT; /** * The message encoding. * Options: "8bit", "7bit", "binary", "base64", and "quoted-printable". * * @var string */ public $Encoding = self::ENCODING_8BIT; /** * Holds the most recent mailer error message. * * @var string */ public $ErrorInfo = ''; /** * The From email address for the message. * * @var string */ public $From = ''; /** * The From name of the message. *Changelog
8 changes between 6.7.7 and 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
7.1.0
Method
sanitiseDate() added.verified against source7.0.4
Method
parseSendmailPath() added.verified against source6.9.7
Method
parseSimplerAddresses() added.verified against source6.9.7
Method
parseEmailString() added.verified against source6.9.7
Method
decodeHeader() added.verified against source6.9.7
Method
addressHasUnicodeLocalPart() added.verified against source6.9.7
Method
anyAddressHasUnicodeLocalPart() added.verified against source6.9.7
Method
needsSMTPUTF8() added.verified against sourceAbout this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/PHPMailer/PHPMailer.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.