PHPMailer\PHPMailer\PHPMailer
PHPMailer - PHP email creation and transport class.
- Author: Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
Synopsis
class PHPMailer
{
- // constants
- const VERSION = '6.0.3';
- const STOP_MESSAGE = 0;
- const STOP_CONTINUE = 1;
- const STOP_CRITICAL = 2;
- const MAX_LINE_LENGTH = 998;
- const STD_LINE_LENGTH = 76;
- // members
- public $Priority;
- public string $CharSet = 'iso-8859-1';
- public string $ContentType = 'text/plain';
- public string $Encoding = '8bit';
- public string $ErrorInfo = '';
- public string $From = 'root@localhost';
- public string $FromName = 'Root User';
- public string $Sender = '';
- public string $Subject = '';
- public string $Body = '';
- public string $AltBody = '';
- public string $Ical = '';
- protected string $MIMEBody = '';
- protected string $MIMEHeader = '';
- protected string $mailHeader = '';
- public integer $WordWrap = 0;
- public string $Mailer = 'mail';
- public string $Sendmail = '/usr/sbin/sendmail';
- public bool $UseSendmailOptions = true;
- public string $ConfirmReadingTo = '';
- public string $Hostname = '';
- public string $MessageID = '';
- public string $MessageDate = '';
- public string $Host = 'localhost';
- public integer $Port = 25;
- public string $Helo = '';
- public string $SMTPSecure = '';
- public bool $SMTPAutoTLS = true;
- public bool $SMTPAuth = false;
- public array $SMTPOptions = ;
- public string $Username = '';
- public string $Password = '';
- public string $AuthType = '';
- protected OAuth $oauth;
- public integer $Timeout = 300;
- public integer $SMTPDebug = 0;
- public LoggerInterface $Debugoutput = 'echo';
- public bool $SMTPKeepAlive = false;
- public bool $SingleTo = false;
- protected array $SingleToArray = ;
- public bool $do_verp = false;
- public bool $AllowEmpty = false;
- public string $DKIM_selector = '';
- public string $DKIM_identity = '';
- public string $DKIM_passphrase = '';
- public string $DKIM_domain = '';
- public string $DKIM_private = '';
- public string $DKIM_private_string = '';
- public string $action_function = '';
- public string $XMailer = '';
- public static string|callable $validator = 'php';
- protected SMTP $smtp;
- protected array $to = ;
- protected array $cc = ;
- protected array $bcc = ;
- protected array $ReplyTo = ;
- protected array $all_recipients = ;
- protected array $RecipientsQueue = ;
- protected array $ReplyToQueue = ;
- protected array $attachment = ;
- protected array $CustomHeader = ;
- protected string $lastMessageID = '';
- protected string $message_type = '';
- protected array $boundary = ;
- protected array $language = ;
- protected integer $error_count = 0;
- protected string $sign_cert_file = '';
- protected string $sign_key_file = '';
- protected string $sign_extracerts_file = '';
- protected string $sign_key_pass = '';
- protected bool $exceptions = false;
- protected string $uniqueid = '';
- protected static string $LE = "\r\n";
- // methods
- public void __construct()
- public void __destruct()
- private bool mailPassthru()
- protected void edebug()
- public void isHTML()
- public void isSMTP()
- public void isMail()
- public void isSendmail()
- public void isQmail()
- public bool addAddress()
- public bool addCC()
- public bool addBCC()
- public bool addReplyTo()
- protected bool addOrEnqueueAnAddress()
- protected bool addAnAddress()
- public static array parseAddresses()
- public bool setFrom()
- public string getLastMessageID()
- public static bool validateAddress()
- public static bool idnSupported()
- public string punyencodeAddress()
- public bool send()
- public bool preSend()
- public bool postSend()
- protected bool sendmailSend()
- protected static bool isShellSafe()
- protected bool mailSend()
- public SMTP getSMTPInstance()
- public SMTP setSMTPInstance()
- protected bool smtpSend()
- public bool smtpConnect()
- public void smtpClose()
- public bool setLanguage()
- public array getTranslations()
- public string addrAppend()
- public string addrFormat()
- public string wrapText()
- public int utf8CharBoundary()
- public void setWordWrap()
- public string createHeader()
- public string getMailMIME()
- public string getSentMIMEMessage()
- protected string generateId()
- public string createBody()
- protected string getBoundary()
- protected string endBoundary()
- protected void setMessageType()
- public string headerLine()
- public string textLine()
- public bool addAttachment()
- public array getAttachments()
- protected string attachAll()
- protected string encodeFile()
- public string encodeString()
- public string encodeHeader()
- public bool hasMultiBytes()
- public bool has8bitChars()
- public string base64EncodeWrapMB()
- public string encodeQP()
- public string encodeQ()
- public void addStringAttachment()
- public bool addEmbeddedImage()
- public bool addStringEmbeddedImage()
- protected bool cidExists()
- public bool inlineImageExists()
- public bool attachmentExists()
- public bool alternativeExists()
- public void clearQueuedAddresses()
- public void clearAddresses()
- public void clearCCs()
- public void clearBCCs()
- public void clearReplyTos()
- public void clearAllRecipients()
- public void clearAttachments()
- public void clearCustomHeaders()
- protected void setError()
- public static string rfcDate()
- protected string serverHostname()
- public static bool isValidHost()
- protected string lang()
- public bool isError()
- public void addCustomHeader()
- public array getCustomHeaders()
- public string msgHTML()
- public string html2text()
- public static string _mime_types()
- public static string filenameToType()
- public static string|array mb_pathinfo()
- public bool set()
- public string secureHeader()
- public static string normalizeBreaks()
- public static string getLE()
- protected static void setLE()
- public void sign()
- public string DKIM_QP()
- public string DKIM_Sign()
- public string DKIM_HeaderC()
- public string DKIM_BodyC()
- public string DKIM_Add()
- public static bool hasLineLongerThanMax()
- public array getToAddresses()
- public array getCcAddresses()
- public array getBccAddresses()
- public array getReplyToAddresses()
- public array getAllRecipientAddresses()
- protected void doCallback()
- public OAuth getOAuth()
- public void setOAuth()
Constants
Name | Value |
---|---|
VERSION | '6.0.3' |
STOP_MESSAGE | 0 |
STOP_CONTINUE | 1 |
STOP_CRITICAL | 2 |
MAX_LINE_LENGTH | 998 |
STD_LINE_LENGTH | 76 |
Members
protected
- $CustomHeader
—
array
The array of custom headers. - $LE
—
string
SMTP RFC standard line ending. - $MIMEBody
—
string
The complete compiled MIME message body. - $MIMEHeader
—
string
The complete compiled MIME message headers. - $RecipientsQueue
—
array
An array of names and addresses queued for validation. - $ReplyTo
—
array
The array of reply-to names and addresses. - $ReplyToQueue
—
array
An array of reply-to names and addresses queued for validation. - $SingleToArray
—
array
Storage for addresses when SingleTo is enabled. - $all_recipients
—
array
An array of all kinds of addresses. - $attachment
—
array
The array of attachments. - $bcc
—
array
The array of 'bcc' names and addresses. - $boundary
—
array
The array of MIME boundary strings. - $cc
—
array
The array of 'cc' names and addresses. - $error_count
—
int
The number of errors encountered. - $exceptions
—
PHPMailer\PHPMailer\bool
Whether to throw exceptions for errors. - $language
—
array
The array of available languages. - $lastMessageID
—
string
The most recent Message-ID (including angular brackets). - $mailHeader
—
string
Extra headers that createHeader() doesn't fold in. - $message_type
—
string
The message's MIME type. - $oauth
—
PHPMailer\PHPMailer\OAuth
An instance of the PHPMailer OAuth class. - $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. - $smtp
—
PHPMailer\PHPMailer\SMTP
An instance of the SMTP sender class. - $to
—
array
The array of 'to' names and addresses. - $uniqueid
—
string
Unique ID used for message ID and boundaries.
public
- $AllowEmpty
—
PHPMailer\PHPMailer\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. - $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. - $Debugoutput
—
PHPMailer\PHPMailer\string|callable|\Psr\Log\LoggerInterface
How to handle debug output. - $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. - $SMTPAuth
—
PHPMailer\PHPMailer\bool
Whether to use SMTP authentication. - $SMTPAutoTLS
—
PHPMailer\PHPMailer\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
—
PHPMailer\PHPMailer\bool
Whether to keep SMTP connection open after each message. - $SMTPOptions
—
array
Options array passed to stream_context_create when connecting via SMTP. - $SMTPSecure
—
string
What kind of encryption to use on the SMTP connection. - $Sender
—
string
The envelope sender of the message. - $Sendmail
—
string
The path to the sendmail program. - $SingleTo
—
PHPMailer\PHPMailer\bool
Whether to split multiple to addresses into multiple messages or send them all in one message. - $Subject
—
string
The Subject of the message. - $Timeout
—
int
The SMTP server timeout in seconds. - $UseSendmailOptions
—
PHPMailer\PHPMailer\bool
Whether mail() uses a fully sendmail-compatible MTA. - $Username
—
string
SMTP username. - $WordWrap
—
int
Word-wrap the message body to this number of chars. - $XMailer
—
string
What to put in the X-Mailer header. - $action_function
—
string
Callback Action function name. - $do_verp
—
PHPMailer\PHPMailer\bool
Whether to generate VERP addresses on send. - $validator
—
PHPMailer\PHPMailer\string|callable
Which validator to use by default when validating email addresses.
Methods
private
- mailPassthru() — Call mail() in a safe_mode-aware fashion.
protected
- addAnAddress() — Add an address to one of the recipient arrays or to the ReplyTo array.
- 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().
- attachAll() — Attach all file, string, and binary attachments to the message.
- cidExists() — Check if an embedded attachment is present with this cid.
- doCallback() — Perform a callback.
- edebug() — Output debugging info via user-defined method.
- encodeFile() — Encode a file attachment in requested format.
- endBoundary() — Return the end of a message boundary.
- generateId() — Create a unique ID to use for boundaries.
- getBoundary() — Return the start of a message boundary.
- isShellSafe() — Fix CVE-2016-10033 and CVE-2016-10045 by disallowing potentially unsafe shell characters.
- lang() — Get an error message in the current language.
- mailSend() — Send mail using the PHP mail() function.
- sendmailSend() — Send mail using the $Sendmail program.
- serverHostname() — Get the server hostname.
- setError() — Add an error message to the error container.
- setLE() — Set the line break format string, e.g. "\r\n".
- setMessageType() — Set the message type.
- smtpSend() — Send mail via SMTP.
public
- __construct() — Constructor.
- __destruct() — Destructor.
- DKIM_Add() — Create the DKIM header and body in a new message header.
- DKIM_BodyC() — Generate a DKIM canonicalization body.
- DKIM_HeaderC() — Generate a DKIM canonicalization header.
- DKIM_QP() — Quoted-Printable-encode a DKIM header.
- DKIM_Sign() — Generate a DKIM signature.
- _mime_types() — Get the MIME type for a file extension.
- addAddress() — Add a "To" address.
- addAttachment() — Add an attachment from a path on the filesystem.
- addBCC() — Add a "BCC" address.
- addCC() — Add a "CC" address.
- addCustomHeader() — Add a custom header.
- addEmbeddedImage() — Add an embedded (inline) attachment from a file.
- addReplyTo() — Add a "Reply-To" address.
- addStringAttachment() — Add a string or binary attachment (non-filesystem).
- addStringEmbeddedImage() — Add an embedded stringified attachment.
- addrAppend() — Create recipient headers.
- addrFormat() — Format an address for use in a message header.
- alternativeExists() — Check if this message has an alternative body set.
- attachmentExists() — Check if an attachment (non-inline) is present.
- base64EncodeWrapMB() — Encode and wrap long multibyte strings for mail headers without breaking lines within a character.
- clearAddresses() — Clear all To recipients.
- clearAllRecipients() — Clear all recipient types.
- clearAttachments() — Clear all filesystem, string, and binary attachments.
- clearBCCs() — Clear all BCC recipients.
- clearCCs() — Clear all CC recipients.
- clearCustomHeaders() — Clear all custom headers.
- clearQueuedAddresses() — Clear queued addresses of given kind.
- clearReplyTos() — Clear all ReplyTo recipients.
- createBody() — Assemble the message body.
- createHeader() — Assemble message headers.
- encodeHeader() — Encode a header value (not including its label) optimally.
- encodeQ() — Encode a string using Q encoding.
- encodeQP() — Encode a string in quoted-printable format.
- encodeString() — Encode a string in requested format.
- filenameToType() — Map a file name to a MIME type.
- getAllRecipientAddresses() — Allows for public read access to 'all_recipients' property.
- getAttachments() — Return the array of attachments.
- getBccAddresses() — Allows for public read access to 'bcc' property.
- getCcAddresses() — Allows for public read access to 'cc' property.
- getCustomHeaders() — Returns all custom headers.
- getLE() — Return the current line break format string.
- getLastMessageID() — Return the Message-ID header of the last email.
- getMailMIME() — Get the message MIME type headers.
- getOAuth() — Get the OAuth instance.
- getReplyToAddresses() — Allows for public read access to 'ReplyTo' property.
- getSMTPInstance() — Get an instance to use for SMTP operations.
- getSentMIMEMessage() — Returns the whole MIME message.
- getToAddresses() — Allows for public read access to 'to' property.
- getTranslations() — Get the array of strings for the current language.
- has8bitChars() — Does a string contain any 8-bit chars (in any charset)?
- hasLineLongerThanMax() — Detect if a string contains a line longer than the maximum line length allowed by RFC 2822 section 2.1.1.
- hasMultiBytes() — Check if a string contains multi-byte characters.
- headerLine() — Format a header line.
- html2text() — Convert an HTML string into plain text.
- idnSupported() — Tells whether IDNs (Internationalized Domain Names) are supported or not. This requires the `intl` and `mbstring` PHP extensions.
- inlineImageExists() — Check if an inline attachment is present.
- isError() — Check if an error occurred.
- isHTML() — Sets message type to HTML or plain.
- isMail() — Send messages using PHP's mail() function.
- isQmail() — Send messages using qmail.
- isSMTP() — Send messages using SMTP.
- isSendmail() — Send messages using $Sendmail.
- isValidHost() — Validate whether a string contains a valid value to use as a hostname or IP address.
- mb_pathinfo() — Multi-byte-safe pathinfo replacement.
- msgHTML() — Create a message body from an HTML string.
- normalizeBreaks() — Normalize line breaks in a 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.
- postSend() — Actually send a message via the selected mechanism.
- preSend() — Prepare a message for sending.
- punyencodeAddress() — Converts IDN in given email address to its ASCII form, also known as punycode, if possible.
- rfcDate() — Return an RFC 822 formatted date.
- secureHeader() — Strip newlines to prevent header injection.
- send() — Create a message and send it.
- set() — Set or reset instance properties.
- setFrom() — Set the From and FromName properties.
- setLanguage() — Set the language for error messages.
- setOAuth() — Set an OAuth instance.
- setSMTPInstance() — Provide an instance to use for SMTP operations.
- setWordWrap() — Apply word wrapping to the message body.
- sign() — Set the public and private key files and password for S/MIME signing.
- smtpClose() — Close the active SMTP session if one exists.
- smtpConnect() — Initiate a connection to an SMTP server.
- textLine() — Return a formatted mail line.
- utf8CharBoundary() — Find the last character boundary prior to $maxLength in a utf-8 quoted-printable encoded string.
- validateAddress() — Check that a string looks like an email address.
- wrapText() — Word-wrap message.