PHP Класс PHPMailer\PHPMailer\PHPMailer

Автор: Marcus Bointon (Synchro/coolbru) ([email protected])
Автор: Jim Jagielski (jimjag) ([email protected])
Автор: Andy Prevost (codeworxtech) ([email protected])
Автор: Brent R. Matzelle (original founder)
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$AllowEmpty boolean Whether to allow sending messages with an empty body.
$AltBody string 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 string Options are LOGIN (default), PLAIN, NTLM, CRAM-MD5, XOAUTH2
$Body string If HTML then call isHTML(true).
$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 Usually the email address used as the source of the email
$DKIM_passphrase string Used if your key is encrypted.
$DKIM_private string DKIM private key file path.
$DKIM_selector string DKIM selector.
$Debugoutput string | callable Options: * echo Output plain-text as-is, appropriate for CLI * html Output escaped, line breaks converted to
, appropriate for browser output * error_log Output to error log as configured in php.ini By default PHPMailer will use echo if run from a cli or cli-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";};
$Encoding string Options: "8bit", "7bit", "binary", "base64", and "quoted-printable".
$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 Default is $Hostname. If $Hostname is empty, PHPMailer attempts to find one with the same method described above for $Hostname.
$Host string 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 string If empty, PHPMailer attempts to find one with, in order, $_SERVER['SERVER_NAME'], gethostname(), php_uname('n'), or the value 'localhost.localdomain'.
$Ical string Only supported in simple alt or alt_inline message types To generate iCal events, use the bundled extras/EasyPeasyICS.php class or iCalcreator
$LE string The default line ending.
$Mailer string Options: "mail", "sendmail", or "smtp".
$MessageDate string If empty, the current date will be added.
$MessageID string If empty, a unique id will be generated.
$Password string SMTP password.
$Port integer The default SMTP server port.
$Priority integer Options: null (default), 1 = High, 3 = Normal, 5 = low. When null, the header is not set at all.
$SMTPAuth boolean Uses the Username and Password properties.
$SMTPAutoTLS boolean Be aware that in PHP >= 5.6 this requires that the server's certificates are valid.
$SMTPDebug integer Debug output level. Options: * 0 No output * 1 Commands * 2 Data and commands * 3 As 2 plus connection status * 4 Low-level data output
$SMTPKeepAlive boolean If this is set to true then to close the connection requires an explicit call to smtpClose().
$SMTPOptions array Options array passed to stream_context_create when connecting via SMTP.
$SMTPSecure string Options: '', 'ssl' or 'tls'
$Sender string If not empty, will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.
$Sendmail string The path to the sendmail program.
$SingleTo boolean Only supported in mail and sendmail transports, not in SMTP.
$Subject string The Subject of the message.
$Timeout integer Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2
$UseSendmailOptions boolean One which supports sendmail's "-oi -f" options.
$Username string SMTP username.
$WordWrap integer Set to 0 to not wrap. A useful value here is 78, for RFC2822 section 2.1.1 compliance.
$XMailer string Options: An empty string for PHPMailer default, whitespace for none, or a string to use
$action_function string 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: boolean $result result of the send action string $to email address of the recipient string $cc cc email addresses string $bcc bcc email addresses string $subject the subject string $body the email body string $from email address of sender
$do_verp boolean Only applicable when sending via SMTP.
$validator string | callable May be a callable to inject your own validator, but there are several built-in validators.

Защищенные свойства (Protected)

Свойство Тип Описание
$CustomHeader array The array of custom headers.
$MIMEBody string The complete compiled MIME message body.
$MIMEHeader string The complete compiled MIME message headers.
$RecipientsQueue array 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.
$ReplyTo array The array of reply-to names and addresses.
$ReplyToQueue array In send(), valid and non duplicate entries are moved to $ReplyTo. This array is used only for addresses with IDN.
$SingleToArray array Storage for addresses when SingleTo is enabled.
$all_recipients array Includes all of $to, $cc, $bcc
$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 integer The number of errors encountered.
$exceptions boolean 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 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 Used only if the key is encrypted.
$smtp 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.

Открытые методы

Метод Описание
DKIM_Add ( string $headers_line, string $subject, string $body ) : string Create the DKIM header and body in a new message header.
DKIM_BodyC ( string $body ) : string Generate a DKIM canonicalization body.
DKIM_HeaderC ( string $signHeader ) : string Generate a DKIM canonicalization header.
DKIM_QP ( string $txt ) : string Quoted-Printable-encode a DKIM header.
DKIM_Sign ( string $signHeader ) : string Generate a DKIM signature.
__construct ( boolean $exceptions = null ) Constructor.
__destruct ( ) Destructor.
_mime_types ( string $ext = '' ) : string Get the MIME type for a file extension.
addAddress ( string $address, string $name = '' ) : boolean Add a "To" address.
addAttachment ( string $path, string $name = '', string $encoding = 'base64', string $type = '', string $disposition = 'attachment' ) : boolean Add an attachment from a path on the filesystem.
addBCC ( string $address, string $name = '' ) : boolean Add a "BCC" address.
addCC ( string $address, string $name = '' ) : boolean Add a "CC" address.
addCustomHeader ( string $name, string $value = null ) : void Add a custom header.
addEmbeddedImage ( string $path, string $cid, string $name = '', string $encoding = 'base64', string $type = '', string $disposition = 'inline' ) : boolean Add an embedded (inline) attachment from a file.
addReplyTo ( string $address, string $name = '' ) : boolean Add a "Reply-To" address.
addStringAttachment ( string $string, string $filename, string $encoding = 'base64', string $type = '', string $disposition = 'attachment' ) : void Add a string or binary attachment (non-filesystem).
addStringEmbeddedImage ( string $string, string $cid, string $name = '', string $encoding = 'base64', string $type = '', string $disposition = 'inline' ) : boolean Add an embedded stringified attachment.
addrAppend ( string $type, array $addr ) : string Create recipient headers.
addrFormat ( array $addr ) : string Format an address for use in a message header.
alternativeExists ( ) : boolean Check if this message has an alternative body set.
attachmentExists ( ) : boolean Check if an attachment (non-inline) is present.
base64EncodeWrapMB ( string $str, string $linebreak = null ) : string Encode and wrap long multibyte strings for mail headers without breaking lines within a character.
clearAddresses ( ) : void Clear all To recipients.
clearAllRecipients ( ) : void Clear all recipient types.
clearAttachments ( ) : void Clear all filesystem, string, and binary attachments.
clearBCCs ( ) : void Clear all BCC recipients.
clearCCs ( ) : void Clear all CC recipients.
clearCustomHeaders ( ) : void Clear all custom headers.
clearQueuedAddresses ( string $kind ) : void Clear queued addresses of given kind.
clearReplyTos ( ) : void Clear all ReplyTo recipients.
createBody ( ) : string Assemble the message body.
createHeader ( ) : string Assemble message headers.
encodeHeader ( string $str, string $position = 'text' ) : string Encode a header string optimally.
encodeQ ( string $str, string $position = 'text' ) : string Encode a string using Q encoding.
encodeQP ( string $string ) : string Encode a string in quoted-printable format.
encodeString ( string $str, string $encoding = 'base64' ) : string Encode a string in requested format.
filenameToType ( string $filename ) : string Map a file name to a MIME type.
fixEOL ( string $str ) : string Ensure consistent line endings in a string.
getAllRecipientAddresses ( ) : array Allows for public read access to 'all_recipients' property.
getAttachments ( ) : array Return the array of attachments.
getBccAddresses ( ) : array Allows for public read access to 'bcc' property.
getCcAddresses ( ) : array Allows for public read access to 'cc' property.
getCustomHeaders ( ) : array Returns all custom headers.
getLastMessageID ( ) : string Return the Message-ID header of the last email.
getMailMIME ( ) : string Get the message MIME type headers.
getOAuth ( ) : OAuth Get the OAuth instance.
getReplyToAddresses ( ) : array Allows for public read access to 'ReplyTo' property.
getSMTPInstance ( ) : SMTP Get an instance to use for SMTP operations.
getSentMIMEMessage ( ) : string Returns the whole MIME message.
getToAddresses ( ) : array Allows for public read access to 'to' property.
getTranslations ( ) : array Get the array of strings for the current language.
has8bitChars ( string $text ) : boolean Does a string contain any 8-bit chars (in any charset)?
hasLineLongerThanMax ( string $str ) : boolean Detect if a string contains a line longer than the maximum line length allowed.
hasMultiBytes ( string $str ) : boolean Check if a string contains multi-byte characters.
headerLine ( string $name, string $value ) : string Format a header line.
html2text ( string $html, boolean | callable $advanced = false ) : string Convert an HTML string into plain text.
idnSupported ( ) : boolean Tells whether IDNs (Internationalized Domain Names) are supported or not. This requires the "intl" and "mbstring" PHP extensions.
inlineImageExists ( ) : boolean Check if an inline attachment is present.
isError ( ) : boolean Check if an error occurred.
isHTML ( boolean $isHtml = true ) : void Sets message type to HTML or plain.
isMail ( ) : void Send messages using PHP's mail() function.
isQmail ( ) : void Send messages using qmail.
isSMTP ( ) : void Send messages using SMTP.
isSendmail ( ) : void Send messages using $Sendmail.
mb_pathinfo ( string $path, integer | string $options = null ) : string | array Multi-byte-safe pathinfo replacement.
msgHTML ( string $message, string $basedir = '', boolean | callable $advanced = false ) : string Create a message from an HTML string.
normalizeBreaks ( string $text, string $breaktype = " " ) : string Normalize line breaks in a string.
parseAddresses ( string $addrstr, boolean $useimap = true ) : array 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.
postSend ( ) : boolean Actually send a message.
preSend ( ) : boolean Prepare a message for sending.
punyencodeAddress ( string $address ) : 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 $str ) : string Strip newlines to prevent header injection.
send ( ) : boolean Create a message and send it.
set ( string $name, mixed $value = '' ) : boolean Set or reset instance properties.
setFrom ( string $address, string $name = '', boolean $auto = true ) : boolean Set the From and FromName properties.
setLanguage ( string $langcode = 'en', string $lang_path = '' ) : boolean Set the language for error messages.
setOAuth ( OAuth $oauth ) Set an OAuth instance.
setWordWrap ( ) : void Apply word wrapping to the message body.
sign ( string $cert_filename, string $key_filename, string $key_pass, string $extracerts_filename = '' ) Set the public and private key files and password for S/MIME signing.
smtpClose ( ) : void Close the active SMTP session if one exists.
smtpConnect ( array $options = [] ) : boolean Initiate a connection to an SMTP server.
textLine ( string $value ) : string Return a formatted mail line.
utf8CharBoundary ( string $encodedText, integer $maxLength ) : integer Find the last character boundary prior to $maxLength in a utf-8 quoted-printable encoded string.
validateAddress ( string $address, string | callable $patternselect = null ) : boolean Check that a string looks like an email address.
wrapText ( string $message, integer $length, boolean $qp_mode = false ) : string Word-wrap message.

Защищенные методы

Метод Описание
addAnAddress ( string $kind, string $address, string $name = '' ) : boolean Add an address to one of the recipient arrays or to the ReplyTo array.
addOrEnqueueAnAddress ( string $kind, string $address, string $name ) : boolean 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 $disposition_type, string $boundary ) : string Attach all file, string, and binary attachments to the message.
cidExists ( $cid ) : boolean Check if an embedded attachment is present with this cid.
doCallback ( boolean $isSent, array $to, array $cc, array $bcc, string $subject, string $body, string $from ) Perform a callback.
edebug ( string $str ) Output debugging info via user-defined method.
encodeFile ( string $path, string $encoding = 'base64' ) : string Encode a file attachment in requested format.
endBoundary ( string $boundary ) : string Return the end of a message boundary.
getBoundary ( string $boundary, string $charSet, string $contentType, string $encoding ) : string Return the start of a message boundary.
lang ( string $key ) : string Get an error message in the current language.
mailSend ( string $header, string $body ) : boolean Send mail using the PHP mail() function.
sendmailSend ( string $header, string $body ) : boolean Send mail using the $Sendmail program.
serverHostname ( ) : string Get the server hostname.
setError ( string $msg ) : void Add an error message to the error container.
setMessageType ( ) : void Set the message type.
smtpSend ( string $header, string $body ) : boolean Send mail via SMTP.

Приватные методы

Метод Описание
mailPassthru ( string $to, string $subject, string $body, string $header, string $params ) : boolean Call mail() in a safe_mode-aware fashion.

Описание методов

DKIM_Add() публичный метод

Create the DKIM header and body in a new message header.
public DKIM_Add ( string $headers_line, string $subject, string $body ) : string
$headers_line string Header lines
$subject string Subject
$body string Body
Результат string

DKIM_BodyC() публичный метод

Uses the 'simple' algorithm from RFC6376 section 3.4.3
public DKIM_BodyC ( string $body ) : string
$body string Message Body
Результат string

DKIM_HeaderC() публичный метод

Uses the 'relaxed' algorithm from RFC6376 section 3.4.2
public DKIM_HeaderC ( string $signHeader ) : string
$signHeader string Header
Результат string

DKIM_QP() публичный метод

Quoted-Printable-encode a DKIM header.
public DKIM_QP ( string $txt ) : string
$txt string
Результат string

DKIM_Sign() публичный метод

Generate a DKIM signature.
public DKIM_Sign ( string $signHeader ) : string
$signHeader string
Результат string

__construct() публичный метод

Constructor.
public __construct ( boolean $exceptions = null )
$exceptions boolean Should we throw external exceptions?

__destruct() публичный метод

Destructor.
public __destruct ( )

_mime_types() публичный статический метод

Get the MIME type for a file extension.
public static _mime_types ( string $ext = '' ) : string
$ext string File extension
Результат string MIME type of file.

addAddress() публичный метод

Add a "To" address.
public addAddress ( string $address, string $name = '' ) : boolean
$address string The email address to send to
$name string
Результат boolean true on success, false if address already used or invalid in some way

addAnAddress() защищенный метод

Addresses that have been added already return false, but do not throw exceptions.
protected addAnAddress ( string $kind, string $address, string $name = '' ) : boolean
$kind string One of 'to', 'cc', 'bcc', or 'ReplyTo'
$address string The email address to send, resp. to reply to
$name string
Результат boolean true on success, false if address already used or invalid in some way

addAttachment() публичный метод

Returns false if the file could not be found or read.
public addAttachment ( string $path, string $name = '', string $encoding = 'base64', string $type = '', string $disposition = 'attachment' ) : boolean
$path string Path to the attachment.
$name string Overrides the attachment name.
$encoding string File encoding (see $Encoding).
$type string File extension (MIME) type.
$disposition string Disposition to use
Результат boolean

addBCC() публичный метод

Add a "BCC" address.
public addBCC ( string $address, string $name = '' ) : boolean
$address string The email address to send to
$name string
Результат boolean true on success, false if address already used or invalid in some way

addCC() публичный метод

Add a "CC" address.
public addCC ( string $address, string $name = '' ) : boolean
$address string The email address to send to
$name string
Результат boolean true on success, false if address already used or invalid in some way

addCustomHeader() публичный метод

$name value can be overloaded to contain both header name and value (name:value)
public addCustomHeader ( string $name, string $value = null ) : void
$name string Custom header name
$value string Header value
Результат void

addEmbeddedImage() публичный метод

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.
public addEmbeddedImage ( string $path, string $cid, string $name = '', string $encoding = 'base64', string $type = '', string $disposition = 'inline' ) : boolean
$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 File encoding (see $Encoding).
$type string File MIME type.
$disposition string Disposition to use
Результат boolean True on successfully adding an attachment

addOrEnqueueAnAddress() защищенный метод

Addresses that have been added already return false, but do not throw exceptions.
protected addOrEnqueueAnAddress ( string $kind, string $address, string $name ) : boolean
$kind string One of 'to', 'cc', 'bcc', or 'ReplyTo'
$address string The email address to send, resp. to reply to
$name string
Результат boolean true on success, false if address already used or invalid in some way

addReplyTo() публичный метод

Add a "Reply-To" address.
public addReplyTo ( string $address, string $name = '' ) : boolean
$address string The email address to reply to
$name string
Результат boolean true on success, false if address already used or invalid in some way

addStringAttachment() публичный метод

This method can be used to attach ascii or binary data, such as a BLOB record from a database.
public addStringAttachment ( string $string, string $filename, string $encoding = 'base64', string $type = '', string $disposition = 'attachment' ) : void
$string string String attachment data.
$filename string Name of the attachment.
$encoding string File encoding (see $Encoding).
$type string File extension (MIME) type.
$disposition string Disposition to use
Результат void

addStringEmbeddedImage() публичный метод

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'.
public addStringEmbeddedImage ( string $string, string $cid, string $name = '', string $encoding = 'base64', string $type = '', string $disposition = 'inline' ) : boolean
$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 File encoding (see $Encoding).
$type string MIME type.
$disposition string Disposition to use
Результат boolean True on successfully adding an attachment

addrAppend() публичный метод

Create recipient headers.
public addrAppend ( string $type, array $addr ) : string
$type string
$addr array An array of recipient, where each recipient is a 2-element indexed array with element 0 containing an address and element 1 containing a name, like: [['[email protected]', 'Joe User'], ['[email protected]', 'Zoe User']]
Результат string

addrFormat() публичный метод

Format an address for use in a message header.
public addrFormat ( array $addr ) : string
$addr array A 2-element indexed array, element 0 containing an address, element 1 containing a name like ['[email protected]', 'Joe User']
Результат string

alternativeExists() публичный метод

Check if this message has an alternative body set.
public alternativeExists ( ) : boolean
Результат boolean

attachAll() защищенный метод

Returns an empty string on failure.
protected attachAll ( string $disposition_type, string $boundary ) : string
$disposition_type string
$boundary string
Результат string

attachmentExists() публичный метод

Check if an attachment (non-inline) is present.
public attachmentExists ( ) : boolean
Результат boolean

base64EncodeWrapMB() публичный метод

Adapted from a function by paravoid
public base64EncodeWrapMB ( string $str, string $linebreak = null ) : string
$str string multi-byte text to wrap encode
$linebreak string string to use as linefeed/end-of-line
Результат string

cidExists() защищенный метод

Check if an embedded attachment is present with this cid.
protected cidExists ( $cid ) : boolean
$cid
Результат boolean

clearAddresses() публичный метод

Clear all To recipients.
public clearAddresses ( ) : void
Результат void

clearAllRecipients() публичный метод

Clear all recipient types.
public clearAllRecipients ( ) : void
Результат void

clearAttachments() публичный метод

Clear all filesystem, string, and binary attachments.
public clearAttachments ( ) : void
Результат void

clearBCCs() публичный метод

Clear all BCC recipients.
public clearBCCs ( ) : void
Результат void

clearCCs() публичный метод

Clear all CC recipients.
public clearCCs ( ) : void
Результат void

clearCustomHeaders() публичный метод

Clear all custom headers.
public clearCustomHeaders ( ) : void
Результат void

clearQueuedAddresses() публичный метод

Clear queued addresses of given kind.
public clearQueuedAddresses ( string $kind ) : void
$kind string 'to', 'cc', or 'bcc'
Результат void

clearReplyTos() публичный метод

Clear all ReplyTo recipients.
public clearReplyTos ( ) : void
Результат void

createBody() публичный метод

Returns an empty string on failure.
public createBody ( ) : string
Результат string The assembled message body

createHeader() публичный метод

Assemble message headers.
public createHeader ( ) : string
Результат string The assembled headers

doCallback() защищенный метод

Perform a callback.
protected doCallback ( boolean $isSent, array $to, array $cc, array $bcc, string $subject, string $body, string $from )
$isSent boolean
$to array
$cc array
$bcc array
$subject string
$body string
$from string

edebug() защищенный метод

Only generates output if SMTP debug output is enabled (@see SMTP::$do_debug).
См. также: PHPMailer::$Debugoutput
См. также: PHPMailer::$SMTPDebug
protected edebug ( string $str )
$str string

encodeFile() защищенный метод

Returns an empty string on failure.
protected encodeFile ( string $path, string $encoding = 'base64' ) : string
$path string The full path to the file
$encoding string The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable'
Результат string

encodeHeader() публичный метод

Picks shortest of Q, B, quoted-printable or none.
public encodeHeader ( string $str, string $position = 'text' ) : string
$str string
$position string
Результат string

encodeQ() публичный метод

Encode a string using Q encoding.
public encodeQ ( string $str, string $position = 'text' ) : string
$str string the text to encode
$position string Where the text is going to be used, see the RFC for what that means
Результат string

encodeQP() публичный метод

According to RFC2045 section 6.7.
public encodeQP ( string $string ) : string
$string string The text to encode
Результат string

encodeString() публичный метод

Returns an empty string on failure.
public encodeString ( string $str, string $encoding = 'base64' ) : string
$str string The text to encode
$encoding string The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable'
Результат string

endBoundary() защищенный метод

Return the end of a message boundary.
protected endBoundary ( string $boundary ) : string
$boundary string
Результат string

filenameToType() публичный статический метод

Defaults to 'application/octet-stream', i.e.. arbitrary binary data.
public static filenameToType ( string $filename ) : string
$filename string A file name or full path, does not need to exist as a file
Результат string

fixEOL() публичный метод

Changes every end of line from CRLF, CR or LF to $this->LE.
public fixEOL ( string $str ) : string
$str string String to fixEOL
Результат string

getAllRecipientAddresses() публичный метод

Allows for public read access to 'all_recipients' property.
public getAllRecipientAddresses ( ) : array
Результат array

getAttachments() публичный метод

Return the array of attachments.
public getAttachments ( ) : array
Результат array

getBccAddresses() публичный метод

Allows for public read access to 'bcc' property.
public getBccAddresses ( ) : array
Результат array

getBoundary() защищенный метод

Return the start of a message boundary.
protected getBoundary ( string $boundary, string $charSet, string $contentType, string $encoding ) : string
$boundary string
$charSet string
$contentType string
$encoding string
Результат string

getCcAddresses() публичный метод

Allows for public read access to 'cc' property.
public getCcAddresses ( ) : array
Результат array

getCustomHeaders() публичный метод

Returns all custom headers.
public getCustomHeaders ( ) : array
Результат array

getLastMessageID() публичный метод

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.
public getLastMessageID ( ) : string
Результат string

getMailMIME() публичный метод

Get the message MIME type headers.
public getMailMIME ( ) : string
Результат string

getOAuth() публичный метод

Get the OAuth instance.
public getOAuth ( ) : OAuth
Результат OAuth

getReplyToAddresses() публичный метод

Allows for public read access to 'ReplyTo' property.
public getReplyToAddresses ( ) : array
Результат array

getSMTPInstance() публичный метод

Override this function to load your own SMTP implementation
public getSMTPInstance ( ) : SMTP
Результат SMTP

getSentMIMEMessage() публичный метод

Includes complete headers and body. Only valid post preSend().
См. также: PHPMailer::preSend()
public getSentMIMEMessage ( ) : string
Результат string

getToAddresses() публичный метод

Allows for public read access to 'to' property.
public getToAddresses ( ) : array
Результат array

getTranslations() публичный метод

Get the array of strings for the current language.
public getTranslations ( ) : array
Результат array

has8bitChars() публичный метод

Does a string contain any 8-bit chars (in any charset)?
public has8bitChars ( string $text ) : boolean
$text string
Результат boolean

hasLineLongerThanMax() публичный статический метод

Detect if a string contains a line longer than the maximum line length allowed.
public static hasLineLongerThanMax ( string $str ) : boolean
$str string
Результат boolean

hasMultiBytes() публичный метод

Check if a string contains multi-byte characters.
public hasMultiBytes ( string $str ) : boolean
$str string multi-byte text to wrap encode
Результат boolean

headerLine() публичный метод

Format a header line.
public headerLine ( string $name, string $value ) : string
$name string
$value string
Результат string

html2text() публичный метод

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: 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(); });
public html2text ( string $html, boolean | callable $advanced = false ) : string
$html string The HTML text to convert
$advanced boolean | callable Any boolean value to use the internal converter, or provide your own callable for custom conversion.
Результат string

idnSupported() публичный метод

Tells whether IDNs (Internationalized Domain Names) are supported or not. This requires the "intl" and "mbstring" PHP extensions.
public idnSupported ( ) : boolean
Результат boolean "true" if required functions for IDN support are present

inlineImageExists() публичный метод

Check if an inline attachment is present.
public inlineImageExists ( ) : boolean
Результат boolean

isError() публичный метод

Check if an error occurred.
public isError ( ) : boolean
Результат boolean True if an error did occur.

isHTML() публичный метод

Sets message type to HTML or plain.
public isHTML ( boolean $isHtml = true ) : void
$isHtml boolean True for HTML mode.
Результат void

isMail() публичный метод

Send messages using PHP's mail() function.
public isMail ( ) : void
Результат void

isQmail() публичный метод

Send messages using qmail.
public isQmail ( ) : void
Результат void

isSMTP() публичный метод

Send messages using SMTP.
public isSMTP ( ) : void
Результат void

isSendmail() публичный метод

Send messages using $Sendmail.
public isSendmail ( ) : void
Результат void

lang() защищенный метод

Get an error message in the current language.
protected lang ( string $key ) : string
$key string
Результат string

mailSend() защищенный метод

Send mail using the PHP mail() function.
protected mailSend ( string $header, string $body ) : boolean
$header string The message headers
$body string The message body
Результат boolean

mb_pathinfo() публичный статический метод

Drop-in replacement for pathinfo(), but multibyte- and cross-platform-safe
public static mb_pathinfo ( string $path, integer | string $options = null ) : string | array
$path string A filename or path, does not need to exist as a file
$options integer | string Either a PATHINFO_* constant, or a string name to return only the specified piece
Результат string | array

msgHTML() публичный метод

Automatically makes modifications for inline images and backgrounds and creates a plain-text version by converting the HTML. Overwrites any existing values in $this->Body and $this->AltBody
public msgHTML ( string $message, string $basedir = '', boolean | callable $advanced = false ) : string
$message string HTML message string
$basedir string baseline directory for path, with or without a trailing slash
$advanced boolean | callable Whether to use the internal HTML to text converter or your own custom converter @see PHPMailer::html2text()
Результат string $message

normalizeBreaks() публичный статический метод

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.
public static normalizeBreaks ( string $text, string $breaktype = " " ) : string
$text string
$breaktype string What kind of line break to use, defaults to CRLF
Результат string

parseAddresses() публичный статический метод

Uses the imap_rfc822_parse_adrlist function if the IMAP extension is available. Note that quotes in the name part are removed.
public static parseAddresses ( string $addrstr, boolean $useimap = true ) : array
$addrstr string The address list string
$useimap boolean Whether to use the IMAP extension to parse the list
Результат array

postSend() публичный метод

Send the email via the selected mechanism
public postSend ( ) : boolean
Результат boolean

preSend() публичный метод

Prepare a message for sending.
public preSend ( ) : boolean
Результат boolean

punyencodeAddress() публичный метод

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)
См. также: PHPMailer::$CharSet
public punyencodeAddress ( string $address ) : string
$address string The email address to convert
Результат string The encoded address in ASCII form

rfcDate() публичный статический метод

Return an RFC 822 formatted date.
public static rfcDate ( ) : string
Результат string

secureHeader() публичный метод

Strip newlines to prevent header injection.
public secureHeader ( string $str ) : string
$str string
Результат string

send() публичный метод

Uses the sending method specified by $Mailer.
public send ( ) : boolean
Результат boolean false on error - See the ErrorInfo property for details of the error.

sendmailSend() защищенный метод

Send mail using the $Sendmail program.
См. также: PHPMailer::$Sendmail
protected sendmailSend ( string $header, string $body ) : boolean
$header string The message headers
$body string The message body
Результат boolean

serverHostname() защищенный метод

Returns 'localhost.localdomain' if unknown.
protected serverHostname ( ) : string
Результат string

set() публичный метод

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';
public set ( string $name, mixed $value = '' ) : boolean
$name string The property name to set
$value mixed The value to set the property to
Результат boolean

setError() защищенный метод

Add an error message to the error container.
protected setError ( string $msg ) : void
$msg string
Результат void

setFrom() публичный метод

Set the From and FromName properties.
public setFrom ( string $address, string $name = '', boolean $auto = true ) : boolean
$address string
$name string
$auto boolean Whether to also set the Sender address, defaults to true
Результат boolean

setLanguage() публичный метод

Returns false if it cannot load the language file. The default language is English.
public setLanguage ( string $langcode = 'en', string $lang_path = '' ) : boolean
$langcode string 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)
Результат boolean

setMessageType() защищенный метод

PHPMailer only supports some preset message types, not arbitrary MIME structures.
protected setMessageType ( ) : void
Результат void

setOAuth() публичный метод

Set an OAuth instance.
public setOAuth ( OAuth $oauth )
$oauth OAuth

setWordWrap() публичный метод

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.
public setWordWrap ( ) : void
Результат void

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 = '' )
$cert_filename string
$key_filename string
$key_pass string Password for private key
$extracerts_filename string Optional path to chain certificate

smtpClose() публичный метод

Close the active SMTP session if one exists.
public smtpClose ( ) : void
Результат void

smtpConnect() публичный метод

Returns false if the operation failed.
public smtpConnect ( array $options = [] ) : boolean
$options array An array of options compatible with stream_context_create()
Результат boolean

smtpSend() защищенный метод

Returns false if there is a bad MAIL FROM, RCPT, or DATA input. Uses the PHPMailerSMTP class by default.
См. также: PHPMailer::getSMTPInstance() to use a different class.
protected smtpSend ( string $header, string $body ) : boolean
$header string The message headers
$body string The message body
Результат boolean

textLine() публичный метод

Return a formatted mail line.
public textLine ( string $value ) : string
$value string
Результат string

utf8CharBoundary() публичный метод

Original written by Colin Brown.
public utf8CharBoundary ( string $encodedText, integer $maxLength ) : integer
$encodedText string utf-8 QP text
$maxLength integer Find the last character boundary prior to this length
Результат integer

validateAddress() публичный статический метод

Check that a string looks like an email address.
public static validateAddress ( string $address, string | callable $patternselect = null ) : boolean
$address string The email address to check
$patternselect string | callable A selector for the validation pattern to use : * `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('[email protected]', 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.
Результат boolean

wrapText() публичный метод

For use with mailers that do not automatically perform wrapping and for quoted-printable encoded messages. Original written by philippe.
public wrapText ( string $message, integer $length, boolean $qp_mode = false ) : string
$message string The message to wrap
$length integer The line length to wrap to
$qp_mode boolean Whether to run in Quoted-Printable mode
Результат string

Описание свойств

$AllowEmpty публичное свойство

Whether to allow sending messages with an empty body.
public bool $AllowEmpty
Результат boolean

$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.
public string $AltBody
Результат string

$AuthType публичное свойство

Options are LOGIN (default), PLAIN, NTLM, CRAM-MD5, XOAUTH2
public string $AuthType
Результат string

$Body публичное свойство

If HTML then call isHTML(true).
public string $Body
Результат string

$CharSet публичное свойство

The character set of the message.
public string $CharSet
Результат string

$ConfirmReadingTo публичное свойство

The email address that a reading confirmation should be sent to, also known as read receipt.
public string $ConfirmReadingTo
Результат string

$ContentType публичное свойство

The MIME Content-type of the message.
public string $ContentType
Результат string

$CustomHeader защищенное свойство

The array of custom headers.
protected array $CustomHeader
Результат array

$DKIM_domain публичное свойство

DKIM signing domain name.
public string $DKIM_domain
Результат string

$DKIM_identity публичное свойство

Usually the email address used as the source of the email
public string $DKIM_identity
Результат string

$DKIM_passphrase публичное свойство

Used if your key is encrypted.
public string $DKIM_passphrase
Результат string

$DKIM_private публичное свойство

DKIM private key file path.
public string $DKIM_private
Результат string

$DKIM_selector публичное свойство

DKIM selector.
public string $DKIM_selector
Результат string

$Debugoutput публичное свойство

Options: * echo Output plain-text as-is, appropriate for CLI * html Output escaped, line breaks converted to
, appropriate for browser output * error_log Output to error log as configured in php.ini By default PHPMailer will use echo if run from a cli or cli-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";};
См. также: SMTP::$Debugoutput
public string|callable $Debugoutput
Результат string | callable

$Encoding публичное свойство

Options: "8bit", "7bit", "binary", "base64", and "quoted-printable".
public string $Encoding
Результат string

$ErrorInfo публичное свойство

Holds the most recent mailer error message.
public string $ErrorInfo
Результат string

$From публичное свойство

The From email address for the message.
public string $From
Результат string

$FromName публичное свойство

The From name of the message.
public string $FromName
Результат string

$Helo публичное свойство

Default is $Hostname. If $Hostname is empty, PHPMailer attempts to find one with the same method described above for $Hostname.
См. также: PHPMailer::$Hostname
public string $Helo
Результат string

$Host публичное свойство

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.
public string $Host
Результат string

$Hostname публичное свойство

If empty, PHPMailer attempts to find one with, in order, $_SERVER['SERVER_NAME'], gethostname(), php_uname('n'), or the value 'localhost.localdomain'.
public string $Hostname
Результат string

$Ical публичное свойство

Only supported in simple alt or alt_inline message types To generate iCal events, use the bundled extras/EasyPeasyICS.php class or iCalcreator
public string $Ical
Результат string

$LE публичное свойство

The default line ending.
public string $LE
Результат string

$MIMEBody защищенное свойство

The complete compiled MIME message body.
protected string $MIMEBody
Результат string

$MIMEHeader защищенное свойство

The complete compiled MIME message headers.
protected string $MIMEHeader
Результат string

$Mailer публичное свойство

Options: "mail", "sendmail", or "smtp".
public string $Mailer
Результат string

$MessageDate публичное свойство

If empty, the current date will be added.
public string $MessageDate
Результат string

$MessageID публичное свойство

If empty, a unique id will be generated.
public string $MessageID
Результат string

$Password публичное свойство

SMTP password.
public string $Password
Результат string

$Port публичное свойство

The default SMTP server port.
public int $Port
Результат integer

$Priority публичное свойство

Options: null (default), 1 = High, 3 = Normal, 5 = low. When null, the header is not set at all.
public int $Priority
Результат integer

$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.
См. также: PHPMailer::$to @see PHPMailer::$cc @see PHPMailer::$bcc
См. также: PHPMailer::$all_recipients
protected array $RecipientsQueue
Результат array

$ReplyTo защищенное свойство

The array of reply-to names and addresses.
protected array $ReplyTo
Результат array

$ReplyToQueue защищенное свойство

In send(), valid and non duplicate entries are moved to $ReplyTo. This array is used only for addresses with IDN.
См. также: PHPMailer::$ReplyTo
protected array $ReplyToQueue
Результат array

$SMTPAuth публичное свойство

Uses the Username and Password properties.
См. также: PHPMailer::$Username
См. также: PHPMailer::$Password
public bool $SMTPAuth
Результат boolean

$SMTPAutoTLS публичное свойство

Be aware that in PHP >= 5.6 this requires that the server's certificates are valid.
public bool $SMTPAutoTLS
Результат boolean

$SMTPDebug публичное свойство

Debug output level. Options: * 0 No output * 1 Commands * 2 Data and commands * 3 As 2 plus connection status * 4 Low-level data output
См. также: SMTP::$do_debug
public int $SMTPDebug
Результат integer

$SMTPKeepAlive публичное свойство

If this is set to true then to close the connection requires an explicit call to smtpClose().
public bool $SMTPKeepAlive
Результат boolean

$SMTPOptions публичное свойство

Options array passed to stream_context_create when connecting via SMTP.
public array $SMTPOptions
Результат array

$SMTPSecure публичное свойство

Options: '', 'ssl' or 'tls'
public string $SMTPSecure
Результат string

$Sender публичное свойство

If not empty, will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.
public string $Sender
Результат string

$Sendmail публичное свойство

The path to the sendmail program.
public string $Sendmail
Результат string

$SingleTo публичное свойство

Only supported in mail and sendmail transports, not in SMTP.
public bool $SingleTo
Результат boolean

$SingleToArray защищенное свойство

Storage for addresses when SingleTo is enabled.
protected array $SingleToArray
Результат array

$Subject публичное свойство

The Subject of the message.
public string $Subject
Результат string

$Timeout публичное свойство

Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2
public int $Timeout
Результат integer

$UseSendmailOptions публичное свойство

One which supports sendmail's "-oi -f" options.
public bool $UseSendmailOptions
Результат boolean

$Username публичное свойство

SMTP username.
public string $Username
Результат string

$WordWrap публичное свойство

Set to 0 to not wrap. A useful value here is 78, for RFC2822 section 2.1.1 compliance.
public int $WordWrap
Результат integer

$XMailer публичное свойство

Options: An empty string for PHPMailer default, whitespace for none, or a string to use
public string $XMailer
Результат 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: boolean $result result of the send action string $to email address of the recipient string $cc cc email addresses string $bcc bcc email addresses string $subject the subject string $body the email body string $from email address of sender
public string $action_function
Результат string

$all_recipients защищенное свойство

Includes all of $to, $cc, $bcc
См. также: PHPMailer::$to @see PHPMailer::$cc @see PHPMailer::$bcc
protected array $all_recipients
Результат array

$attachment защищенное свойство

The array of attachments.
protected array $attachment
Результат array

$bcc защищенное свойство

The array of 'bcc' names and addresses.
protected array $bcc
Результат array

$boundary защищенное свойство

The array of MIME boundary strings.
protected array $boundary
Результат array

$cc защищенное свойство

The array of 'cc' names and addresses.
protected array $cc
Результат array

$do_verp публичное свойство

Only applicable when sending via SMTP.
public bool $do_verp
Результат boolean

$error_count защищенное свойство

The number of errors encountered.
protected int $error_count
Результат integer

$exceptions защищенное свойство

Whether to throw exceptions for errors.
protected bool $exceptions
Результат boolean

$language защищенное свойство

The array of available languages.
protected array $language
Результат array

$lastMessageID защищенное свойство

The most recent Message-ID (including angular brackets).
protected string $lastMessageID
Результат string

$mailHeader защищенное свойство

Extra headers that createHeader() doesn't fold in.
protected string $mailHeader
Результат string

$message_type защищенное свойство

The message's MIME type.
protected string $message_type
Результат string

$oauth защищенное свойство

An instance of the PHPMailer OAuth class.
protected OAuth,PHPMailer\PHPMailer $oauth
Результат OAuth

$sign_cert_file защищенное свойство

The S/MIME certificate file path.
protected string $sign_cert_file
Результат string

$sign_extracerts_file защищенное свойство

The optional S/MIME extra certificates ("CA Chain") file path.
protected string $sign_extracerts_file
Результат string

$sign_key_file защищенное свойство

The S/MIME key file path.
protected string $sign_key_file
Результат string

$sign_key_pass защищенное свойство

Used only if the key is encrypted.
protected string $sign_key_pass
Результат string

$smtp защищенное свойство

An instance of the SMTP sender class.
protected SMTP,PHPMailer\PHPMailer $smtp
Результат SMTP

$to защищенное свойство

The array of 'to' names and addresses.
protected array $to
Результат array

$uniqueid защищенное свойство

Unique ID used for message ID and boundaries.
protected string $uniqueid
Результат string

$validator публичное статическое свойство

May be a callable to inject your own validator, but there are several built-in validators.
См. также: PHPMailer::validateAddress()
public static string|callable $validator
Результат string | callable