PHP Класс PHPMailer

Показать файл Открыть проект Примеры использования класса

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

Свойство Тип Описание
$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 CRAM-MD5, LOGIN, PLAIN, NTLM, XOAUTH2, attempted in that order if not specified
$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_private_string string If set, takes precedence over $DKIM_private.
$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 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. You can set your own, but it must be in the format "", as defined in RFC5322 section 3.6.4 or it will be ignored.
$Password string SMTP password.
$PluginDir string Useful if the SMTP class is not in the PHP include path.
$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.
$Realm string Used for NTLM auth
$ReturnPath string If empty, it will be set to either From or Sender.
$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.
$SingleToArray array Storage for addresses when SingleTo is enabled.
$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.
$Version string The PHPMailer Version number.
$WordWrap integer Set to 0 to not wrap. A useful value here is 78, for RFC2822 section 2.1.1 compliance.
$Workstation string Used for NTLM auth
$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.
$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.
$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, integer $line_max = 76 ) : string Encode a string in quoted-printable format.
encodeQPphp ( string $string, integer $line_max = 76, boolean $space_conv = false ) : string Backward compatibility wrapper for an old QP encoding function that was removed.
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.
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 body 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.
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 = null ) : 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.
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.
generateId ( ) : string Create unique ID
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() публичный Метод

Generate a DKIM canonicalization body.
public DKIM_BodyC ( string $body ) : string
$body string Message Body
Результат string

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

Generate a DKIM canonicalization header.
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 The DKIM signature value

__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: array(array('[email protected]', 'Joe User'), array('[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 array('[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

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, integer $line_max = 76 ) : string
$string string The text to encode
$line_max integer Number of chars allowed on a line before wrapping
Результат string

encodeQPphp() публичный Метод

Backward compatibility wrapper for an old QP encoding function that was removed.
См. также: PHPMailer::encodeQP()
Устаревший: Use encodeQP instead.
public encodeQPphp ( string $string, integer $line_max = 76, boolean $space_conv = false ) : string
$string string
$line_max integer
$space_conv boolean
Результат 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

generateId() защищенный Метод

Create unique ID
protected generateId ( ) : string
Результат 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

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-safe, cross-platform-safe, old-version-safe. Works similarly to the one in PHP >= 5.2.0
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, allows 'filename' to work on PHP < 5.2
Результат string | array

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

Automatically inlines images and creates a plain-text version by converting the HTML, overwriting any existing values in Body and AltBody. $basedir is used when handling relative image paths, e.g. will look for an image file in $basedir/images/a.png and convert it to inline. If you don't want to apply these transformations to your HTML, just set Body and AltBody yourself.
public msgHTML ( string $message, string $basedir = '', boolean | callable $advanced = false ) : string
$message string HTML message string
$basedir string base directory for relative paths to images
$advanced boolean | callable Whether to use the internal HTML to text converter or your own custom converter @see PHPMailer::html2text()
Результат string $message The transformed message Body

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

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 = null ) : 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, PHP >= 5.3.2, 5.2.14; * `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 CRAM-MD5, LOGIN, PLAIN, NTLM, XOAUTH2, attempted in that order if not specified
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_private_string публичное свойство

If set, takes precedence over $DKIM_private.
public string $DKIM_private_string
Результат 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 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. You can set your own, but it must be in the format "", as defined in RFC5322 section 3.6.4 or it will be ignored.
См. также: https://tools.ietf.org/html/rfc5322#section-3.6.4
public string $MessageID
Результат string

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

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

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

Useful if the SMTP class is not in the PHP include path.
Устаревший: Should not be needed now there is an autoloader.
public string $PluginDir
Результат 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

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

Used for NTLM auth
public string $Realm
Результат string

$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

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

If empty, it will be set to either From or Sender.
Устаревший: Email senders should never set a return-path header; it's the receiver's job (RFC5321 section 4.4), so this no longer does anything.
public string $ReturnPath
Результат string

$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.
public 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

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

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

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

Used for NTLM auth
public string $Workstation
Результат string

$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

$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 $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