PHPMailer
in package
PHPMailer - PHP email creation and transport class.
Tags
Table of Contents
- MAX_LINE_LENGTH = 998
- The maximum line length allowed by RFC 2822 section 2.1.1.
- STD_LINE_LENGTH = 76
- The lower maximum line length allowed by RFC 2822 section 2.1.1.
- STOP_CONTINUE = 1
- Error severity: message, likely ok to continue processing.
- STOP_CRITICAL = 2
- Error severity: message, plus full stop, critical error reached.
- STOP_MESSAGE = 0
- Error severity: message only, continue processing.
- VERSION = '6.0.1'
- The PHPMailer Version number.
- $action_function : string
- Callback Action function name.
- $AllowEmpty : bool
- Whether to allow sending messages with an empty body.
- $AltBody : string
- The plain-text message body.
- $AuthType : string
- SMTP auth type.
- $Body : string
- An HTML or plain text message body.
- $CharSet : string
- The character set of the message.
- $ConfirmReadingTo : string
- The email address that a reading confirmation should be sent to, also known as read receipt.
- $ContentType : string
- The MIME Content-type of the message.
- $Debugoutput : string|callable|LoggerInterface
- How to handle debug output.
- $DKIM_domain : string
- DKIM signing domain name.
- $DKIM_identity : string
- DKIM Identity.
- $DKIM_passphrase : string
- DKIM passphrase.
- $DKIM_private : string
- DKIM private key file path.
- $DKIM_private_string : string
- DKIM private key string.
- $DKIM_selector : string
- DKIM selector.
- $do_verp : bool
- Whether to generate VERP addresses on send.
- $Encoding : string
- The message encoding.
- $ErrorInfo : string
- Holds the most recent mailer error message.
- $From : string
- The From email address for the message.
- $FromName : string
- The From name of the message.
- $Helo : string
- The SMTP HELO of the message.
- $Host : string
- SMTP hosts.
- $Hostname : string
- The hostname to use in the Message-ID header and as default HELO string.
- $Ical : string
- An iCal message part body.
- $Mailer : string
- Which method to use to send mail.
- $MessageDate : string
- The message Date to be used in the Date header.
- $MessageID : string
- An ID to be used in the Message-ID header.
- $Password : string
- SMTP password.
- $Port : int
- The default SMTP server port.
- $Priority : int
- Email priority.
- $Sender : string
- The envelope sender of the message.
- $Sendmail : string
- The path to the sendmail program.
- $SingleTo : bool
- Whether to split multiple to addresses into multiple messages or send them all in one message.
- $SMTPAuth : bool
- Whether to use SMTP authentication.
- $SMTPAutoTLS : bool
- Whether to enable TLS encryption automatically if a server supports it, even if `SMTPSecure` is not set to 'tls'.
- $SMTPDebug : int
- SMTP class debug output mode.
- $SMTPKeepAlive : bool
- Whether to keep SMTP connection open after each message.
- $SMTPOptions : array<string|int, mixed>
- Options array passed to stream_context_create when connecting via SMTP.
- $SMTPSecure : string
- What kind of encryption to use on the SMTP connection.
- $Subject : string
- The Subject of the message.
- $Timeout : int
- The SMTP server timeout in seconds.
- $Username : string
- SMTP username.
- $UseSendmailOptions : bool
- Whether mail() uses a fully sendmail-compatible MTA.
- $validator : string|callable
- Which validator to use by default when validating email addresses.
- $WordWrap : int
- Word-wrap the message body to this number of chars.
- $XMailer : string
- What to put in the X-Mailer header.
- $all_recipients : array<string|int, mixed>
- An array of all kinds of addresses.
- $attachment : array<string|int, mixed>
- The array of attachments.
- $bcc : array<string|int, mixed>
- The array of 'bcc' names and addresses.
- $boundary : array<string|int, mixed>
- The array of MIME boundary strings.
- $cc : array<string|int, mixed>
- The array of 'cc' names and addresses.
- $CustomHeader : array<string|int, mixed>
- The array of custom headers.
- $error_count : int
- The number of errors encountered.
- $exceptions : bool
- Whether to throw exceptions for errors.
- $language : array<string|int, mixed>
- The array of available languages.
- $lastMessageID : string
- The most recent Message-ID (including angular brackets).
- $LE : string
- SMTP RFC standard line ending.
- $mailHeader : string
- Extra headers that createHeader() doesn't fold in.
- $message_type : string
- The message's MIME type.
- $MIMEBody : string
- The complete compiled MIME message body.
- $MIMEHeader : string
- The complete compiled MIME message headers.
- $oauth : OAuth
- An instance of the PHPMailer OAuth class.
- $RecipientsQueue : array<string|int, mixed>
- An array of names and addresses queued for validation.
- $ReplyTo : array<string|int, mixed>
- The array of reply-to names and addresses.
- $ReplyToQueue : array<string|int, mixed>
- An array of reply-to names and addresses queued for validation.
- $sign_cert_file : string
- The S/MIME certificate file path.
- $sign_extracerts_file : string
- The optional S/MIME extra certificates ("CA Chain") file path.
- $sign_key_file : string
- The S/MIME key file path.
- $sign_key_pass : string
- The S/MIME password for the key.
- $SingleToArray : array<string|int, mixed>
- Storage for addresses when SingleTo is enabled.
- $smtp : SMTP
- An instance of the SMTP sender class.
- $to : array<string|int, mixed>
- The array of 'to' names and addresses.
- $uniqueid : string
- Unique ID used for message ID and boundaries.
- __construct() : mixed
- Constructor.
- __destruct() : mixed
- Destructor.
- _mime_types() : string
- Get the MIME type for a file extension.
- addAddress() : bool
- Add a "To" address.
- addAttachment() : bool
- Add an attachment from a path on the filesystem.
- addBCC() : bool
- Add a "BCC" address.
- addCC() : bool
- Add a "CC" address.
- addCustomHeader() : mixed
- Add a custom header.
- addEmbeddedImage() : bool
- Add an embedded (inline) attachment from a file.
- addrAppend() : string
- Create recipient headers.
- addReplyTo() : bool
- Add a "Reply-To" address.
- addrFormat() : string
- Format an address for use in a message header.
- addStringAttachment() : mixed
- Add a string or binary attachment (non-filesystem).
- addStringEmbeddedImage() : bool
- Add an embedded stringified attachment.
- alternativeExists() : bool
- Check if this message has an alternative body set.
- attachmentExists() : bool
- Check if an attachment (non-inline) is present.
- base64EncodeWrapMB() : string
- Encode and wrap long multibyte strings for mail headers without breaking lines within a character.
- clearAddresses() : mixed
- Clear all To recipients.
- clearAllRecipients() : mixed
- Clear all recipient types.
- clearAttachments() : mixed
- Clear all filesystem, string, and binary attachments.
- clearBCCs() : mixed
- Clear all BCC recipients.
- clearCCs() : mixed
- Clear all CC recipients.
- clearCustomHeaders() : mixed
- Clear all custom headers.
- clearQueuedAddresses() : mixed
- Clear queued addresses of given kind.
- clearReplyTos() : mixed
- Clear all ReplyTo recipients.
- createBody() : string
- Assemble the message body.
- createHeader() : string
- Assemble message headers.
- DKIM_Add() : string
- Create the DKIM header and body in a new message header.
- DKIM_BodyC() : string
- Generate a DKIM canonicalization body.
- DKIM_HeaderC() : string
- Generate a DKIM canonicalization header.
- DKIM_QP() : string
- Quoted-Printable-encode a DKIM header.
- DKIM_Sign() : string
- Generate a DKIM signature.
- encodeHeader() : string
- Encode a header value (not including its label) optimally.
- encodeQ() : string
- Encode a string using Q encoding.
- encodeQP() : string
- Encode a string in quoted-printable format.
- encodeString() : string
- Encode a string in requested format.
- filenameToType() : string
- Map a file name to a MIME type.
- getAllRecipientAddresses() : array<string|int, mixed>
- Allows for public read access to 'all_recipients' property.
- getAttachments() : array<string|int, mixed>
- Return the array of attachments.
- getBccAddresses() : array<string|int, mixed>
- Allows for public read access to 'bcc' property.
- getCcAddresses() : array<string|int, mixed>
- Allows for public read access to 'cc' property.
- getCustomHeaders() : array<string|int, mixed>
- Returns all custom headers.
- getLastMessageID() : string
- Return the Message-ID header of the last email.
- getLE() : string
- Return the current line break format string.
- getMailMIME() : string
- Get the message MIME type headers.
- getOAuth() : OAuth
- Get the OAuth instance.
- getReplyToAddresses() : array<string|int, mixed>
- Allows for public read access to 'ReplyTo' property.
- getSentMIMEMessage() : string
- Returns the whole MIME message.
- getSMTPInstance() : SMTP
- Get an instance to use for SMTP operations.
- getToAddresses() : array<string|int, mixed>
- Allows for public read access to 'to' property.
- getTranslations() : array<string|int, mixed>
- Get the array of strings for the current language.
- has8bitChars() : bool
- Does a string contain any 8-bit chars (in any charset)?
- hasLineLongerThanMax() : bool
- Detect if a string contains a line longer than the maximum line length allowed by RFC 2822 section 2.1.1.
- hasMultiBytes() : bool
- Check if a string contains multi-byte characters.
- headerLine() : string
- Format a header line.
- html2text() : string
- Convert an HTML string into plain text.
- idnSupported() : bool
- Tells whether IDNs (Internationalized Domain Names) are supported or not. This requires the `intl` and `mbstring` PHP extensions.
- inlineImageExists() : bool
- Check if an inline attachment is present.
- isError() : bool
- Check if an error occurred.
- isHTML() : mixed
- Sets message type to HTML or plain.
- isMail() : mixed
- Send messages using PHP's mail() function.
- isQmail() : mixed
- Send messages using qmail.
- isSendmail() : mixed
- Send messages using $Sendmail.
- isSMTP() : mixed
- Send messages using SMTP.
- isValidHost() : bool
- Validate whether a string contains a valid value to use as a hostname or IP address.
- mb_pathinfo() : string|array<string|int, mixed>
- Multi-byte-safe pathinfo replacement.
- msgHTML() : string
- Create a message body from an HTML string.
- normalizeBreaks() : string
- Normalize line breaks in a string.
- parseAddresses() : array<string|int, mixed>
- 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.
- postSend() : bool
- Actually send a message via the selected mechanism.
- preSend() : bool
- Prepare a message for sending.
- punyencodeAddress() : string
- Converts IDN in given email address to its ASCII form, also known as punycode, if possible.
- rfcDate() : string
- Return an RFC 822 formatted date.
- secureHeader() : string
- Strip newlines to prevent header injection.
- send() : bool
- Create a message and send it.
- set() : bool
- Set or reset instance properties.
- setFrom() : bool
- Set the From and FromName properties.
- setLanguage() : bool
- Set the language for error messages.
- setOAuth() : mixed
- Set an OAuth instance.
- setSMTPInstance() : SMTP
- Provide an instance to use for SMTP operations.
- setWordWrap() : mixed
- Apply word wrapping to the message body.
- sign() : mixed
- Set the public and private key files and password for S/MIME signing.
- smtpClose() : mixed
- Close the active SMTP session if one exists.
- smtpConnect() : bool
- Initiate a connection to an SMTP server.
- textLine() : string
- Return a formatted mail line.
- utf8CharBoundary() : int
- Find the last character boundary prior to $maxLength in a utf-8 quoted-printable encoded string.
- validateAddress() : bool
- Check that a string looks like an email address.
- wrapText() : string
- Word-wrap message.
- addAnAddress() : bool
- Add an address to one of the recipient arrays or to the ReplyTo array.
- addOrEnqueueAnAddress() : bool
- 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().
- attachAll() : string
- Attach all file, string, and binary attachments to the message.
- cidExists() : bool
- Check if an embedded attachment is present with this cid.
- doCallback() : mixed
- Perform a callback.
- edebug() : mixed
- Output debugging info via user-defined method.
- encodeFile() : string
- Encode a file attachment in requested format.
- endBoundary() : string
- Return the end of a message boundary.
- generateId() : string
- Create a unique ID to use for boundaries.
- getBoundary() : string
- Return the start of a message boundary.
- isShellSafe() : bool
- Fix CVE-2016-10033 and CVE-2016-10045 by disallowing potentially unsafe shell characters.
- lang() : string
- Get an error message in the current language.
- mailSend() : bool
- Send mail using the PHP mail() function.
- sendmailSend() : bool
- Send mail using the $Sendmail program.
- serverHostname() : string
- Get the server hostname.
- setError() : mixed
- Add an error message to the error container.
- setLE() : mixed
- Set the line break format string, e.g. "\r\n".
- setMessageType() : mixed
- Set the message type.
- smtpSend() : bool
- Send mail via SMTP.
- mailPassthru() : bool
- Call mail() in a safe_mode-aware fashion.
Constants
MAX_LINE_LENGTH
The maximum line length allowed by RFC 2822 section 2.1.1.
public
int
MAX_LINE_LENGTH
= 998
STD_LINE_LENGTH
The lower maximum line length allowed by RFC 2822 section 2.1.1.
public
int
STD_LINE_LENGTH
= 76
This length does NOT include the line break 76 means that lines will be 77 or 78 chars depending on whether the line break format is LF or CRLF; both are valid.
STOP_CONTINUE
Error severity: message, likely ok to continue processing.
public
int
STOP_CONTINUE
= 1
STOP_CRITICAL
Error severity: message, plus full stop, critical error reached.
public
int
STOP_CRITICAL
= 2
STOP_MESSAGE
Error severity: message only, continue processing.
public
int
STOP_MESSAGE
= 0
VERSION
The PHPMailer Version number.
public
string
VERSION
= '6.0.1'
Properties
$action_function
Callback Action function name.
public
string
$action_function
= ''
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: bool $result result of the send action array $to email addresses of the recipients array $cc cc email addresses array $bcc bcc email addresses string $subject the subject string $body the email body string $from email address of sender string $extra extra information of possible use "smtp_transaction_id' => last smtp transaction id
$AllowEmpty
Whether to allow sending messages with an empty body.
public
bool
$AllowEmpty
= false
$AltBody
The plain-text message body.
public
string
$AltBody
= ''
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.
$AuthType
SMTP auth type.
public
string
$AuthType
= ''
Options are CRAM-MD5, LOGIN, PLAIN, XOAUTH2, attempted in that order if not specified.
$Body
An HTML or plain text message body.
public
string
$Body
= ''
If HTML then call isHTML(true).
$CharSet
The character set of the message.
public
string
$CharSet
= 'iso-8859-1'
$ConfirmReadingTo
The email address that a reading confirmation should be sent to, also known as read receipt.
public
string
$ConfirmReadingTo
= ''
$ContentType
The MIME Content-type of the message.
public
string
$ContentType
= 'text/plain'
$Debugoutput
How to handle debug output.
public
string|callable|LoggerInterface
$Debugoutput
= 'echo'
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 By default PHPMailer will useecho
if run from acli
orcli-server
SAPI,html
otherwise. 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";};
Alternatively, you can pass in an instance of a PSR-3 compatible logger, though only debug
level output is used:
$mail->Debugoutput = new myPsr3Logger;
Tags
$DKIM_domain
DKIM signing domain name.
public
string
$DKIM_domain
= ''
Tags
$DKIM_identity
DKIM Identity.
public
string
$DKIM_identity
= ''
Usually the email address used as the source of the email.
$DKIM_passphrase
DKIM passphrase.
public
string
$DKIM_passphrase
= ''
Used if your key is encrypted.
$DKIM_private
DKIM private key file path.
public
string
$DKIM_private
= ''
$DKIM_private_string
DKIM private key string.
public
string
$DKIM_private_string
= ''
If set, takes precedence over $DKIM_private
.
$DKIM_selector
DKIM selector.
public
string
$DKIM_selector
= ''
$do_verp
Whether to generate VERP addresses on send.
public
bool
$do_verp
= false
Only applicable when sending via SMTP.
Tags
$Encoding
The message encoding.
public
string
$Encoding
= '8bit'
Options: "8bit", "7bit", "binary", "base64", and "quoted-printable".
$ErrorInfo
Holds the most recent mailer error message.
public
string
$ErrorInfo
= ''
$From
The From email address for the message.
public
string
$From
= 'root@localhost'
$FromName
The From name of the message.
public
string
$FromName
= 'Root User'
$Helo
The SMTP HELO of the message.
public
string
$Helo
= ''
Default is $Hostname. If $Hostname is empty, PHPMailer attempts to find one with the same method described above for $Hostname.
Tags
$Host
SMTP hosts.
public
string
$Host
= 'localhost'
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.
$Hostname
The hostname to use in the Message-ID header and as default HELO string.
public
string
$Hostname
= ''
If empty, PHPMailer attempts to find one with, in order, $_SERVER['SERVER_NAME'], gethostname(), php_uname('n'), or the value 'localhost.localdomain'.
$Ical
An iCal message part body.
public
string
$Ical
= ''
Only supported in simple alt or alt_inline message types To generate iCal event structures, use classes like EasyPeasyICS or iCalcreator.
Tags
$Mailer
Which method to use to send mail.
public
string
$Mailer
= 'mail'
Options: "mail", "sendmail", or "smtp".
$MessageDate
The message Date to be used in the Date header.
public
string
$MessageDate
= ''
If empty, the current date will be added.
$MessageID
An ID to be used in the Message-ID header.
public
string
$MessageID
= ''
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.
Tags
$Password
SMTP password.
public
string
$Password
= ''
$Port
The default SMTP server port.
public
int
$Port
= 25
$Priority
Email priority.
public
int
$Priority
= null
Options: null (default), 1 = High, 3 = Normal, 5 = low. When null, the header is not set at all.
$Sender
The envelope sender of the message.
public
string
$Sender
= ''
This will usually be turned into a Return-Path header by the receiver,
and is the address that bounces will be sent to.
If not empty, will be passed via -f
to sendmail or as the 'MAIL FROM' value over SMTP.
$Sendmail
The path to the sendmail program.
public
string
$Sendmail
= '/usr/sbin/sendmail'
$SingleTo
Whether to split multiple to addresses into multiple messages or send them all in one message.
public
bool
$SingleTo
= false
Only supported in mail
and sendmail
transports, not in SMTP.
$SMTPAuth
Whether to use SMTP authentication.
public
bool
$SMTPAuth
= false
Uses the Username and Password properties.
Tags
$SMTPAutoTLS
Whether to enable TLS encryption automatically if a server supports it, even if `SMTPSecure` is not set to 'tls'.
public
bool
$SMTPAutoTLS
= true
Be aware that in PHP >= 5.6 this requires that the server's certificates are valid.
$SMTPDebug
SMTP class debug output mode.
public
int
$SMTPDebug
= 0
Debug output level. Options:
-
0
No output -
1
Commands -
2
Data and commands -
3
As 2 plus connection status -
4
Low-level data output.
Tags
$SMTPKeepAlive
Whether to keep SMTP connection open after each message.
public
bool
$SMTPKeepAlive
= false
If this is set to true then to close the connection requires an explicit call to smtpClose().
$SMTPOptions
Options array passed to stream_context_create when connecting via SMTP.
public
array<string|int, mixed>
$SMTPOptions
= []
$SMTPSecure
What kind of encryption to use on the SMTP connection.
public
string
$SMTPSecure
= ''
Options: '', 'ssl' or 'tls'.
$Subject
The Subject of the message.
public
string
$Subject
= ''
$Timeout
The SMTP server timeout in seconds.
public
int
$Timeout
= 300
Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2.
$Username
SMTP username.
public
string
$Username
= ''
$UseSendmailOptions
Whether mail() uses a fully sendmail-compatible MTA.
public
bool
$UseSendmailOptions
= true
One which supports sendmail's "-oi -f" options.
$validator
Which validator to use by default when validating email addresses.
public
static string|callable
$validator
= 'php'
May be a callable to inject your own validator, but there are several built-in validators. The default validator uses PHP's FILTER_VALIDATE_EMAIL filter_var option.
Tags
$WordWrap
Word-wrap the message body to this number of chars.
public
int
$WordWrap
= 0
Set to 0 to not wrap. A useful value here is 78, for RFC2822 section 2.1.1 compliance.
Tags
$XMailer
What to put in the X-Mailer header.
public
string
$XMailer
= ''
Options: An empty string for PHPMailer default, whitespace for none, or a string to use.
$all_recipients
An array of all kinds of addresses.
protected
array<string|int, mixed>
$all_recipients
= []
Includes all of $to, $cc, $bcc.
Tags
$attachment
The array of attachments.
protected
array<string|int, mixed>
$attachment
= []
$bcc
The array of 'bcc' names and addresses.
protected
array<string|int, mixed>
$bcc
= []
$boundary
The array of MIME boundary strings.
protected
array<string|int, mixed>
$boundary
= []
$cc
The array of 'cc' names and addresses.
protected
array<string|int, mixed>
$cc
= []
$CustomHeader
The array of custom headers.
protected
array<string|int, mixed>
$CustomHeader
= []
$error_count
The number of errors encountered.
protected
int
$error_count
= 0
$exceptions
Whether to throw exceptions for errors.
protected
bool
$exceptions
= false
$language
The array of available languages.
protected
array<string|int, mixed>
$language
= []
$lastMessageID
The most recent Message-ID (including angular brackets).
protected
string
$lastMessageID
= ''
$LE
SMTP RFC standard line ending.
protected
static string
$LE
= "
"
$mailHeader
Extra headers that createHeader() doesn't fold in.
protected
string
$mailHeader
= ''
$message_type
The message's MIME type.
protected
string
$message_type
= ''
$MIMEBody
The complete compiled MIME message body.
protected
string
$MIMEBody
= ''
$MIMEHeader
The complete compiled MIME message headers.
protected
string
$MIMEHeader
= ''
$oauth
An instance of the PHPMailer OAuth class.
protected
OAuth
$oauth
= null
$RecipientsQueue
An array of names and addresses queued for validation.
protected
array<string|int, mixed>
$RecipientsQueue
= []
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.
Tags
$ReplyTo
The array of reply-to names and addresses.
protected
array<string|int, mixed>
$ReplyTo
= []
$ReplyToQueue
An array of reply-to names and addresses queued for validation.
protected
array<string|int, mixed>
$ReplyToQueue
= []
In send(), valid and non duplicate entries are moved to $ReplyTo. This array is used only for addresses with IDN.
Tags
$sign_cert_file
The S/MIME certificate file path.
protected
string
$sign_cert_file
= ''
$sign_extracerts_file
The optional S/MIME extra certificates ("CA Chain") file path.
protected
string
$sign_extracerts_file
= ''
$sign_key_file
The S/MIME key file path.
protected
string
$sign_key_file
= ''
$sign_key_pass
The S/MIME password for the key.
protected
string
$sign_key_pass
= ''
Used only if the key is encrypted.
$SingleToArray
Storage for addresses when SingleTo is enabled.
protected
array<string|int, mixed>
$SingleToArray
= []
$smtp
An instance of the SMTP sender class.
protected
SMTP
$smtp
= null
$to
The array of 'to' names and addresses.
protected
array<string|int, mixed>
$to
= []
$uniqueid
Unique ID used for message ID and boundaries.
protected
string
$uniqueid
= ''
Methods
__construct()
Constructor.
public
__construct([bool $exceptions = null ]) : mixed
Parameters
- $exceptions : bool = null
-
Should we throw external exceptions?
Return values
mixed —__destruct()
Destructor.
public
__destruct() : mixed
Return values
mixed —_mime_types()
Get the MIME type for a file extension.
public
static _mime_types([string $ext = '' ]) : string
Parameters
- $ext : string = ''
-
File extension
Return values
string —MIME type of file
addAddress()
Add a "To" address.
public
addAddress(string $address[, string $name = '' ]) : bool
Parameters
- $address : string
-
The email address to send to
- $name : string = ''
Return values
bool —true on success, false if address already used or invalid in some way
addAttachment()
Add an attachment from a path on the filesystem.
public
addAttachment(string $path[, string $name = '' ][, string $encoding = 'base64' ][, string $type = '' ][, string $disposition = 'attachment' ]) : bool
Never use a user-supplied path to a file! Returns false if the file could not be found or read.
Parameters
- $path : string
-
Path to the attachment
- $name : string = ''
-
Overrides the attachment name
- $encoding : string = 'base64'
-
File encoding (see $Encoding)
- $type : string = ''
-
File extension (MIME) type
- $disposition : string = 'attachment'
-
Disposition to use
Tags
Return values
bool —addBCC()
Add a "BCC" address.
public
addBCC(string $address[, string $name = '' ]) : bool
Parameters
- $address : string
-
The email address to send to
- $name : string = ''
Return values
bool —true on success, false if address already used or invalid in some way
addCC()
Add a "CC" address.
public
addCC(string $address[, string $name = '' ]) : bool
Parameters
- $address : string
-
The email address to send to
- $name : string = ''
Return values
bool —true on success, false if address already used or invalid in some way
addCustomHeader()
Add a custom header.
public
addCustomHeader(string $name[, string|null $value = null ]) : mixed
$name value can be overloaded to contain both header name and value (name:value).
Parameters
- $name : string
-
Custom header name
- $value : string|null = null
-
Header value
Return values
mixed —addEmbeddedImage()
Add an embedded (inline) attachment from a file.
public
addEmbeddedImage(string $path, string $cid[, string $name = '' ][, string $encoding = 'base64' ][, string $type = '' ][, string $disposition = 'inline' ]) : bool
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 : string
-
Path to the attachment
- $cid : string
-
Content ID of the attachment; Use this to reference the content when using an embedded image in HTML
- $name : string = ''
-
Overrides the attachment name
- $encoding : string = 'base64'
-
File encoding (see $Encoding)
- $type : string = ''
-
File MIME type
- $disposition : string = 'inline'
-
Disposition to use
Return values
bool —True on successfully adding an attachment
addrAppend()
Create recipient headers.
public
addrAppend(string $type, array<string|int, mixed> $addr) : string
Parameters
- $type : string
- $addr : array<string|int, mixed>
-
An array of recipients, where each recipient is a 2-element indexed array with element 0 containing an address and element 1 containing a name, like: [['joe@example.com', 'Joe User'], ['zoe@example.com', 'Zoe User']]
Return values
string —addReplyTo()
Add a "Reply-To" address.
public
addReplyTo(string $address[, string $name = '' ]) : bool
Parameters
- $address : string
-
The email address to reply to
- $name : string = ''
Return values
bool —true on success, false if address already used or invalid in some way
addrFormat()
Format an address for use in a message header.
public
addrFormat(array<string|int, mixed> $addr) : string
Parameters
- $addr : array<string|int, mixed>
-
A 2-element indexed array, element 0 containing an address, element 1 containing a name like ['joe@example.com', 'Joe User']
Return values
string —addStringAttachment()
Add a string or binary attachment (non-filesystem).
public
addStringAttachment(string $string, string $filename[, string $encoding = 'base64' ][, string $type = '' ][, string $disposition = 'attachment' ]) : mixed
This method can be used to attach ascii or binary data, such as a BLOB record from a database.
Parameters
- $string : string
-
String attachment data
- $filename : string
-
Name of the attachment
- $encoding : string = 'base64'
-
File encoding (see $Encoding)
- $type : string = ''
-
File extension (MIME) type
- $disposition : string = 'attachment'
-
Disposition to use
Return values
mixed —addStringEmbeddedImage()
Add an embedded stringified attachment.
public
addStringEmbeddedImage(string $string, string $cid[, string $name = '' ][, string $encoding = 'base64' ][, string $type = '' ][, string $disposition = 'inline' ]) : bool
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 : string
-
The attachment binary data
- $cid : string
-
Content ID of the attachment; Use this to reference the content when using an embedded image in HTML
- $name : string = ''
- $encoding : string = 'base64'
-
File encoding (see $Encoding)
- $type : string = ''
-
MIME type
- $disposition : string = 'inline'
-
Disposition to use
Return values
bool —True on successfully adding an attachment
alternativeExists()
Check if this message has an alternative body set.
public
alternativeExists() : bool
Return values
bool —attachmentExists()
Check if an attachment (non-inline) is present.
public
attachmentExists() : bool
Return values
bool —base64EncodeWrapMB()
Encode and wrap long multibyte strings for mail headers without breaking lines within a character.
public
base64EncodeWrapMB(string $str[, string $linebreak = null ]) : string
Adapted from a function by paravoid.
Parameters
- $str : string
-
multi-byte text to wrap encode
- $linebreak : string = null
-
string to use as linefeed/end-of-line
Tags
Return values
string —clearAddresses()
Clear all To recipients.
public
clearAddresses() : mixed
Return values
mixed —clearAllRecipients()
Clear all recipient types.
public
clearAllRecipients() : mixed
Return values
mixed —clearAttachments()
Clear all filesystem, string, and binary attachments.
public
clearAttachments() : mixed
Return values
mixed —clearBCCs()
Clear all BCC recipients.
public
clearBCCs() : mixed
Return values
mixed —clearCCs()
Clear all CC recipients.
public
clearCCs() : mixed
Return values
mixed —clearCustomHeaders()
Clear all custom headers.
public
clearCustomHeaders() : mixed
Return values
mixed —clearQueuedAddresses()
Clear queued addresses of given kind.
public
clearQueuedAddresses(string $kind) : mixed
Parameters
- $kind : string
-
'to', 'cc', or 'bcc'
Return values
mixed —clearReplyTos()
Clear all ReplyTo recipients.
public
clearReplyTos() : mixed
Return values
mixed —createBody()
Assemble the message body.
public
createBody() : string
Returns an empty string on failure.
Tags
Return values
string —The assembled message body
createHeader()
Assemble message headers.
public
createHeader() : string
Return values
string —The assembled headers
DKIM_Add()
Create the DKIM header and body in a new message header.
public
DKIM_Add(string $headers_line, string $subject, string $body) : string
Parameters
- $headers_line : string
-
Header lines
- $subject : string
-
Subject
- $body : string
-
Body
Return values
string —DKIM_BodyC()
Generate a DKIM canonicalization body.
public
DKIM_BodyC(string $body) : string
Uses the 'simple' algorithm from RFC6376 section 3.4.3.
Parameters
- $body : string
-
Message Body
Tags
Return values
string —DKIM_HeaderC()
Generate a DKIM canonicalization header.
public
DKIM_HeaderC(string $signHeader) : string
Uses the 'relaxed' algorithm from RFC6376 section 3.4.2.
Parameters
- $signHeader : string
-
Header
Tags
Return values
string —DKIM_QP()
Quoted-Printable-encode a DKIM header.
public
DKIM_QP(string $txt) : string
Parameters
- $txt : string
Return values
string —DKIM_Sign()
Generate a DKIM signature.
public
DKIM_Sign(string $signHeader) : string
Parameters
- $signHeader : string
Tags
Return values
string —The DKIM signature value
encodeHeader()
Encode a header value (not including its label) optimally.
public
encodeHeader(string $str[, string $position = 'text' ]) : string
Picks shortest of Q, B, or none. Result includes folding if needed. See RFC822 definitions for phrase, comment and text positions.
Parameters
- $str : string
-
The header value to encode
- $position : string = 'text'
-
What context the string will be used in
Return values
string —encodeQ()
Encode a string using Q encoding.
public
encodeQ(string $str[, string $position = 'text' ]) : string
Parameters
- $str : string
-
the text to encode
- $position : string = 'text'
-
Where the text is going to be used, see the RFC for what that means
Tags
Return values
string —encodeQP()
Encode a string in quoted-printable format.
public
encodeQP(string $string) : string
According to RFC2045 section 6.7.
Parameters
- $string : string
-
The text to encode
Return values
string —encodeString()
Encode a string in requested format.
public
encodeString(string $str[, string $encoding = 'base64' ]) : string
Returns an empty string on failure.
Parameters
- $str : string
-
The text to encode
- $encoding : string = 'base64'
-
The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable
Return values
string —filenameToType()
Map a file name to a MIME type.
public
static filenameToType(string $filename) : string
Defaults to 'application/octet-stream', i.e.. arbitrary binary data.
Parameters
- $filename : string
-
A file name or full path, does not need to exist as a file
Return values
string —getAllRecipientAddresses()
Allows for public read access to 'all_recipients' property.
public
getAllRecipientAddresses() : array<string|int, mixed>
Before the send() call, queued addresses (i.e. with IDN) are not yet included.
Return values
array<string|int, mixed> —getAttachments()
Return the array of attachments.
public
getAttachments() : array<string|int, mixed>
Return values
array<string|int, mixed> —getBccAddresses()
Allows for public read access to 'bcc' property.
public
getBccAddresses() : array<string|int, mixed>
Before the send() call, queued addresses (i.e. with IDN) are not yet included.
Return values
array<string|int, mixed> —getCcAddresses()
Allows for public read access to 'cc' property.
public
getCcAddresses() : array<string|int, mixed>
Before the send() call, queued addresses (i.e. with IDN) are not yet included.
Return values
array<string|int, mixed> —getCustomHeaders()
Returns all custom headers.
public
getCustomHeaders() : array<string|int, mixed>
Return values
array<string|int, mixed> —getLastMessageID()
Return the Message-ID header of the last email.
public
getLastMessageID() : string
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 values
string —getLE()
Return the current line break format string.
public
static getLE() : string
Return values
string —getMailMIME()
Get the message MIME type headers.
public
getMailMIME() : string
Return values
string —getOAuth()
Get the OAuth instance.
public
getOAuth() : OAuth
Return values
OAuth —getReplyToAddresses()
Allows for public read access to 'ReplyTo' property.
public
getReplyToAddresses() : array<string|int, mixed>
Before the send() call, queued addresses (i.e. with IDN) are not yet included.
Return values
array<string|int, mixed> —getSentMIMEMessage()
Returns the whole MIME message.
public
getSentMIMEMessage() : string
Includes complete headers and body. Only valid post preSend().
Tags
Return values
string —getSMTPInstance()
Get an instance to use for SMTP operations.
public
getSMTPInstance() : SMTP
Override this function to load your own SMTP implementation, or set one with setSMTPInstance.
Return values
SMTP —getToAddresses()
Allows for public read access to 'to' property.
public
getToAddresses() : array<string|int, mixed>
Before the send() call, queued addresses (i.e. with IDN) are not yet included.
Return values
array<string|int, mixed> —getTranslations()
Get the array of strings for the current language.
public
getTranslations() : array<string|int, mixed>
Return values
array<string|int, mixed> —has8bitChars()
Does a string contain any 8-bit chars (in any charset)?
public
has8bitChars(string $text) : bool
Parameters
- $text : string
Return values
bool —hasLineLongerThanMax()
Detect if a string contains a line longer than the maximum line length allowed by RFC 2822 section 2.1.1.
public
static hasLineLongerThanMax(string $str) : bool
Parameters
- $str : string
Return values
bool —hasMultiBytes()
Check if a string contains multi-byte characters.
public
hasMultiBytes(string $str) : bool
Parameters
- $str : string
-
multi-byte text to wrap encode
Return values
bool —headerLine()
Format a header line.
public
headerLine(string $name, string|int $value) : string
Parameters
- $name : string
- $value : string|int
Return values
string —html2text()
Convert an HTML string into plain text.
public
html2text(string $html[, bool|callable $advanced = false ]) : string
This is used by msgHTML(). Note - older versions of this function used a bundled advanced converter which was removed for license reasons in #232. Example usage:
// 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();
});
Parameters
- $html : string
-
The HTML text to convert
- $advanced : bool|callable = false
-
Any boolean value to use the internal converter, or provide your own callable for custom conversion
Return values
string —idnSupported()
Tells whether IDNs (Internationalized Domain Names) are supported or not. This requires the `intl` and `mbstring` PHP extensions.
public
idnSupported() : bool
Return values
bool —true
if required functions for IDN support are present
inlineImageExists()
Check if an inline attachment is present.
public
inlineImageExists() : bool
Return values
bool —isError()
Check if an error occurred.
public
isError() : bool
Return values
bool —True if an error did occur
isHTML()
Sets message type to HTML or plain.
public
isHTML([bool $isHtml = true ]) : mixed
Parameters
- $isHtml : bool = true
-
True for HTML mode
Return values
mixed —isMail()
Send messages using PHP's mail() function.
public
isMail() : mixed
Return values
mixed —isQmail()
Send messages using qmail.
public
isQmail() : mixed
Return values
mixed —isSendmail()
Send messages using $Sendmail.
public
isSendmail() : mixed
Return values
mixed —isSMTP()
Send messages using SMTP.
public
isSMTP() : mixed
Return values
mixed —isValidHost()
Validate whether a string contains a valid value to use as a hostname or IP address.
public
static isValidHost(string $host) : bool
IPv6 addresses must include [], e.g. [::1]
, not just ::1
.
Parameters
- $host : string
-
The host name or IP address to check
Return values
bool —mb_pathinfo()
Multi-byte-safe pathinfo replacement.
public
static mb_pathinfo(string $path[, int|string $options = null ]) : string|array<string|int, mixed>
Drop-in replacement for pathinfo(), but multibyte- and cross-platform-safe.
Parameters
- $path : string
-
A filename or path, does not need to exist as a file
- $options : int|string = null
-
Either a PATHINFO_* constant, or a string name to return only the specified piece
Tags
Return values
string|array<string|int, mixed> —msgHTML()
Create a message body from an HTML string.
public
msgHTML(string $message[, string $basedir = '' ][, bool|callable $advanced = false ]) : 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) Converts data-uri images into embedded attachments. If you don't want to apply these transformations to your HTML, just set Body and AltBody directly.
Parameters
- $message : string
-
HTML message string
- $basedir : string = ''
-
Absolute path to a base directory to prepend to relative paths to images
- $advanced : bool|callable = false
-
Whether to use the internal HTML to text converter or your own custom converter @see PHPMailer::html2text()
Return values
string —$message The transformed message Body
normalizeBreaks()
Normalize line breaks in a string.
public
static normalizeBreaks(string $text[, string $breaktype = null ]) : 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 : string
- $breaktype : string = null
-
What kind of line break to use; defaults to static::$LE
Return values
string —parseAddresses()
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.
public
static parseAddresses(string $addrstr[, bool $useimap = true ]) : array<string|int, mixed>
Uses the imap_rfc822_parse_adrlist function if the IMAP extension is available. Note that quotes in the name part are removed.
Parameters
- $addrstr : string
-
The address list string
- $useimap : bool = true
-
Whether to use the IMAP extension to parse the list
Tags
Return values
array<string|int, mixed> —postSend()
Actually send a message via the selected mechanism.
public
postSend() : bool
Tags
Return values
bool —preSend()
Prepare a message for sending.
public
preSend() : bool
Tags
Return values
bool —punyencodeAddress()
Converts IDN in given email address to its ASCII form, also known as punycode, if possible.
public
punyencodeAddress(string $address) : string
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 contains characters not allowed in an IDN).
Parameters
- $address : string
-
The email address to convert
Tags
Return values
string —The encoded address in ASCII form
rfcDate()
Return an RFC 822 formatted date.
public
static rfcDate() : string
Return values
string —secureHeader()
Strip newlines to prevent header injection.
public
secureHeader(string $str) : string
Parameters
- $str : string
Return values
string —send()
Create a message and send it.
public
send() : bool
Uses the sending method specified by $Mailer.
Tags
Return values
bool —false on error - See the ErrorInfo property for details of the error
set()
Set or reset instance properties.
public
set(string $name[, mixed $value = '' ]) : bool
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 : string
-
The property name to set
- $value : mixed = ''
-
The value to set the property to
Return values
bool —setFrom()
Set the From and FromName properties.
public
setFrom(string $address[, string $name = '' ][, bool $auto = true ]) : bool
Parameters
- $address : string
- $name : string = ''
- $auto : bool = true
-
Whether to also set the Sender address, defaults to true
Tags
Return values
bool —setLanguage()
Set the language for error messages.
public
setLanguage([string $langcode = 'en' ][, string $lang_path = '' ]) : bool
Returns false if it cannot load the language file. The default language is English.
Parameters
- $langcode : string = 'en'
-
ISO 639-1 2-character language code (e.g. French is "fr")
- $lang_path : string = ''
-
Path to the language file directory, with trailing separator (slash)
Return values
bool —setOAuth()
Set an OAuth instance.
public
setOAuth(OAuth $oauth) : mixed
Parameters
- $oauth : OAuth
Return values
mixed —setSMTPInstance()
Provide an instance to use for SMTP operations.
public
setSMTPInstance(SMTP $smtp) : SMTP
Parameters
- $smtp : SMTP
Return values
SMTP —setWordWrap()
Apply word wrapping to the message body.
public
setWordWrap() : mixed
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 values
mixed —sign()
Set the public and private key files and password for S/MIME signing.
public
sign(string $cert_filename, string $key_filename, string $key_pass[, string $extracerts_filename = '' ]) : mixed
Parameters
- $cert_filename : string
- $key_filename : string
- $key_pass : string
-
Password for private key
- $extracerts_filename : string = ''
-
Optional path to chain certificate
Return values
mixed —smtpClose()
Close the active SMTP session if one exists.
public
smtpClose() : mixed
Return values
mixed —smtpConnect()
Initiate a connection to an SMTP server.
public
smtpConnect([array<string|int, mixed> $options = null ]) : bool
Returns false if the operation failed.
Parameters
- $options : array<string|int, mixed> = null
-
An array of options compatible with stream_context_create()
Tags
Return values
bool —textLine()
Return a formatted mail line.
public
textLine(string $value) : string
Parameters
- $value : string
Return values
string —utf8CharBoundary()
Find the last character boundary prior to $maxLength in a utf-8 quoted-printable encoded string.
public
utf8CharBoundary(string $encodedText, int $maxLength) : int
Original written by Colin Brown.
Parameters
- $encodedText : string
-
utf-8 QP text
- $maxLength : int
-
Find the last character boundary prior to this length
Return values
int —validateAddress()
Check that a string looks like an email address.
public
static validateAddress(string $address[, string|callable $patternselect = null ]) : bool
Validation patterns supported:
-
auto
Pick best pattern automatically; -
pcre8
Use the squiloople.com pattern, requires PCRE > 8.0; -
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.
Parameters
- $address : string
-
The email address to check
- $patternselect : string|callable = null
-
Which pattern to use
Return values
bool —wrapText()
Word-wrap message.
public
wrapText(string $message, int $length[, bool $qp_mode = false ]) : string
For use with mailers that do not automatically perform wrapping and for quoted-printable encoded messages. Original written by philippe.
Parameters
- $message : string
-
The message to wrap
- $length : int
-
The line length to wrap to
- $qp_mode : bool = false
-
Whether to run in Quoted-Printable mode
Return values
string —addAnAddress()
Add an address to one of the recipient arrays or to the ReplyTo array.
protected
addAnAddress(string $kind, string $address[, string $name = '' ]) : bool
Addresses that have been added already return false, but do not throw exceptions.
Parameters
- $kind : string
-
One of 'to', 'cc', 'bcc', or 'ReplyTo'
- $address : string
-
The email address to send, resp. to reply to
- $name : string = ''
Tags
Return values
bool —true on success, false if address already used or invalid in some way
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().
protected
addOrEnqueueAnAddress(string $kind, string $address, string $name) : bool
Addresses that have been added already return false, but do not throw exceptions.
Parameters
- $kind : string
-
One of 'to', 'cc', 'bcc', or 'ReplyTo'
- $address : string
-
The email address to send, resp. to reply to
- $name : string
Tags
Return values
bool —true on success, false if address already used or invalid in some way
attachAll()
Attach all file, string, and binary attachments to the message.
protected
attachAll(string $disposition_type, string $boundary) : string
Returns an empty string on failure.
Parameters
- $disposition_type : string
- $boundary : string
Return values
string —cidExists()
Check if an embedded attachment is present with this cid.
protected
cidExists(string $cid) : bool
Parameters
- $cid : string
Return values
bool —doCallback()
Perform a callback.
protected
doCallback(bool $isSent, array<string|int, mixed> $to, array<string|int, mixed> $cc, array<string|int, mixed> $bcc, string $subject, string $body, string $from, array<string|int, mixed> $extra) : mixed
Parameters
- $isSent : bool
- $to : array<string|int, mixed>
- $cc : array<string|int, mixed>
- $bcc : array<string|int, mixed>
- $subject : string
- $body : string
- $from : string
- $extra : array<string|int, mixed>
Return values
mixed —edebug()
Output debugging info via user-defined method.
protected
edebug(string $str) : mixed
Only generates output if SMTP debug output is enabled (@see SMTP::$do_debug).
Parameters
- $str : string
Tags
Return values
mixed —encodeFile()
Encode a file attachment in requested format.
protected
encodeFile(string $path[, string $encoding = 'base64' ]) : string
Returns an empty string on failure.
Parameters
- $path : string
-
The full path to the file
- $encoding : string = 'base64'
-
The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable'
Tags
Return values
string —endBoundary()
Return the end of a message boundary.
protected
endBoundary(string $boundary) : string
Parameters
- $boundary : string
Return values
string —generateId()
Create a unique ID to use for boundaries.
protected
generateId() : string
Return values
string —getBoundary()
Return the start of a message boundary.
protected
getBoundary(string $boundary, string $charSet, string $contentType, string $encoding) : string
Parameters
- $boundary : string
- $charSet : string
- $contentType : string
- $encoding : string
Return values
string —isShellSafe()
Fix CVE-2016-10033 and CVE-2016-10045 by disallowing potentially unsafe shell characters.
protected
static isShellSafe(string $string) : bool
Note that escapeshellarg and escapeshellcmd are inadequate for our purposes, especially on Windows.
Parameters
- $string : string
-
The string to be validated
Tags
Return values
bool —lang()
Get an error message in the current language.
protected
lang(string $key) : string
Parameters
- $key : string
Return values
string —mailSend()
Send mail using the PHP mail() function.
protected
mailSend(string $header, string $body) : bool
Parameters
- $header : string
-
The message headers
- $body : string
-
The message body
Tags
Return values
bool —sendmailSend()
Send mail using the $Sendmail program.
protected
sendmailSend(string $header, string $body) : bool
Parameters
- $header : string
-
The message headers
- $body : string
-
The message body
Tags
Return values
bool —serverHostname()
Get the server hostname.
protected
serverHostname() : string
Returns 'localhost.localdomain' if unknown.
Return values
string —setError()
Add an error message to the error container.
protected
setError(string $msg) : mixed
Parameters
- $msg : string
Return values
mixed —setLE()
Set the line break format string, e.g. "\r\n".
protected
static setLE(string $le) : mixed
Parameters
- $le : string
Return values
mixed —setMessageType()
Set the message type.
protected
setMessageType() : mixed
PHPMailer only supports some preset message types, not arbitrary MIME structures.
Return values
mixed —smtpSend()
Send mail via SMTP.
protected
smtpSend(string $header, string $body) : bool
Returns false if there is a bad MAIL FROM, RCPT, or DATA input.
Parameters
- $header : string
-
The message headers
- $body : string
-
The message body
Tags
Return values
bool —mailPassthru()
Call mail() in a safe_mode-aware fashion.
private
mailPassthru(string $to, string $subject, string $body, string $header, string|null $params) : bool
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 : string
-
To
- $subject : string
-
Subject
- $body : string
-
Message Body
- $header : string
-
Additional Header(s)
- $params : string|null
-
Params