PHP Class PHPMailer

Afficher le fichier Open project: phpmailer/phpmailer Class Usage Examples

Méthodes publiques

Свойство Type Description
$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 Properties

Свойство Type Description
$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.

Méthodes publiques

Méthode Description
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.

Méthodes protégées

Méthode Description
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.

Private Methods

Méthode Description
mailPassthru ( string $to, string $subject, string $body, string $header, string $params ) : boolean Call mail() in a safe_mode-aware fashion.

Method Details

DKIM_Add() public méthode

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
Résultat string

DKIM_BodyC() public méthode

Generate a DKIM canonicalization body.
public DKIM_BodyC ( string $body ) : string
$body string Message Body
Résultat string

DKIM_HeaderC() public méthode

Generate a DKIM canonicalization header.
public DKIM_HeaderC ( string $signHeader ) : string
$signHeader string Header
Résultat string

DKIM_QP() public méthode

Quoted-Printable-encode a DKIM header.
public DKIM_QP ( string $txt ) : string
$txt string
Résultat string

DKIM_Sign() public méthode

Generate a DKIM signature.
public DKIM_Sign ( string $signHeader ) : string
$signHeader string
Résultat string The DKIM signature value

__construct() public méthode

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

__destruct() public méthode

Destructor.
public __destruct ( )

_mime_types() public static méthode

Get the MIME type for a file extension.
public static _mime_types ( string $ext = '' ) : string
$ext string File extension
Résultat string MIME type of file.

addAddress() public méthode

Add a "To" address.
public addAddress ( string $address, string $name = '' ) : boolean
$address string The email address to send to
$name string
Résultat boolean true on success, false if address already used or invalid in some way

addAnAddress() protected méthode

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
Résultat boolean true on success, false if address already used or invalid in some way

addAttachment() public méthode

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
Résultat boolean

addBCC() public méthode

Add a "BCC" address.
public addBCC ( string $address, string $name = '' ) : boolean
$address string The email address to send to
$name string
Résultat boolean true on success, false if address already used or invalid in some way

addCC() public méthode

Add a "CC" address.
public addCC ( string $address, string $name = '' ) : boolean
$address string The email address to send to
$name string
Résultat boolean true on success, false if address already used or invalid in some way

addCustomHeader() public méthode

$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
Résultat void

addEmbeddedImage() public méthode

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
Résultat boolean True on successfully adding an attachment

addOrEnqueueAnAddress() protected méthode

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
Résultat boolean true on success, false if address already used or invalid in some way

addReplyTo() public méthode

Add a "Reply-To" address.
public addReplyTo ( string $address, string $name = '' ) : boolean
$address string The email address to reply to
$name string
Résultat boolean true on success, false if address already used or invalid in some way

addStringAttachment() public méthode

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
Résultat void

addStringEmbeddedImage() public méthode

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
Résultat boolean True on successfully adding an attachment

addrAppend() public méthode

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'))
Résultat string

addrFormat() public méthode

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')
Résultat string

alternativeExists() public méthode

Check if this message has an alternative body set.
public alternativeExists ( ) : boolean
Résultat boolean

attachAll() protected méthode

Returns an empty string on failure.
protected attachAll ( string $disposition_type, string $boundary ) : string
$disposition_type string
$boundary string
Résultat string

attachmentExists() public méthode

Check if an attachment (non-inline) is present.
public attachmentExists ( ) : boolean
Résultat boolean

base64EncodeWrapMB() public méthode

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
Résultat string

clearAddresses() public méthode

Clear all To recipients.
public clearAddresses ( ) : void
Résultat void

clearAllRecipients() public méthode

Clear all recipient types.
public clearAllRecipients ( ) : void
Résultat void

clearAttachments() public méthode

Clear all filesystem, string, and binary attachments.
public clearAttachments ( ) : void
Résultat void

clearBCCs() public méthode

Clear all BCC recipients.
public clearBCCs ( ) : void
Résultat void

clearCCs() public méthode

Clear all CC recipients.
public clearCCs ( ) : void
Résultat void

clearCustomHeaders() public méthode

Clear all custom headers.
public clearCustomHeaders ( ) : void
Résultat void

clearQueuedAddresses() public méthode

Clear queued addresses of given kind.
public clearQueuedAddresses ( string $kind ) : void
$kind string 'to', 'cc', or 'bcc'
Résultat void

clearReplyTos() public méthode

Clear all ReplyTo recipients.
public clearReplyTos ( ) : void
Résultat void

createBody() public méthode

Returns an empty string on failure.
public createBody ( ) : string
Résultat string The assembled message body

createHeader() public méthode

Assemble message headers.
public createHeader ( ) : string
Résultat string The assembled headers

doCallback() protected méthode

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() protected méthode

Only generates output if SMTP debug output is enabled (@see SMTP::$do_debug).
See also: PHPMailer::$Debugoutput
See also: PHPMailer::$SMTPDebug
protected edebug ( string $str )
$str string

encodeFile() protected méthode

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'
Résultat string

encodeHeader() public méthode

Picks shortest of Q, B, quoted-printable or none.
public encodeHeader ( string $str, string $position = 'text' ) : string
$str string
$position string
Résultat string

encodeQ() public méthode

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
Résultat string

encodeQP() public méthode

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
Résultat string

encodeQPphp() public méthode

Backward compatibility wrapper for an old QP encoding function that was removed.
See also: PHPMailer::encodeQP()
Deprecation: Use encodeQP instead.
public encodeQPphp ( string $string, integer $line_max = 76, boolean $space_conv = false ) : string
$string string
$line_max integer
$space_conv boolean
Résultat string

encodeString() public méthode

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'
Résultat string

endBoundary() protected méthode

Return the end of a message boundary.
protected endBoundary ( string $boundary ) : string
$boundary string
Résultat string

filenameToType() public static méthode

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
Résultat string

fixEOL() public méthode

Changes every end of line from CRLF, CR or LF to $this->LE.
public fixEOL ( string $str ) : string
$str string String to fixEOL
Résultat string

generateId() protected méthode

Create unique ID
protected generateId ( ) : string
Résultat string

getAllRecipientAddresses() public méthode

Allows for public read access to 'all_recipients' property.
public getAllRecipientAddresses ( ) : array
Résultat array

getAttachments() public méthode

Return the array of attachments.
public getAttachments ( ) : array
Résultat array

getBccAddresses() public méthode

Allows for public read access to 'bcc' property.
public getBccAddresses ( ) : array
Résultat array

getBoundary() protected méthode

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
Résultat string

getCcAddresses() public méthode

Allows for public read access to 'cc' property.
public getCcAddresses ( ) : array
Résultat array

getCustomHeaders() public méthode

Returns all custom headers.
public getCustomHeaders ( ) : array
Résultat array

getLastMessageID() public méthode

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
Résultat string

getMailMIME() public méthode

Get the message MIME type headers.
public getMailMIME ( ) : string
Résultat string

getReplyToAddresses() public méthode

Allows for public read access to 'ReplyTo' property.
public getReplyToAddresses ( ) : array
Résultat array

getSMTPInstance() public méthode

Override this function to load your own SMTP implementation
public getSMTPInstance ( ) : SMTP
Résultat SMTP

getSentMIMEMessage() public méthode

Includes complete headers and body. Only valid post preSend().
See also: PHPMailer::preSend()
public getSentMIMEMessage ( ) : string
Résultat string

getToAddresses() public méthode

Allows for public read access to 'to' property.
public getToAddresses ( ) : array
Résultat array

getTranslations() public méthode

Get the array of strings for the current language.
public getTranslations ( ) : array
Résultat array

has8bitChars() public méthode

Does a string contain any 8-bit chars (in any charset)?
public has8bitChars ( string $text ) : boolean
$text string
Résultat boolean

hasLineLongerThanMax() public static méthode

Detect if a string contains a line longer than the maximum line length allowed.
public static hasLineLongerThanMax ( string $str ) : boolean
$str string
Résultat boolean

hasMultiBytes() public méthode

Check if a string contains multi-byte characters.
public hasMultiBytes ( string $str ) : boolean
$str string multi-byte text to wrap encode
Résultat boolean

headerLine() public méthode

Format a header line.
public headerLine ( string $name, string $value ) : string
$name string
$value string
Résultat string

html2text() public méthode

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.
Résultat string

idnSupported() public méthode

Tells whether IDNs (Internationalized Domain Names) are supported or not. This requires the "intl" and "mbstring" PHP extensions.
public idnSupported ( ) : boolean
Résultat boolean "true" if required functions for IDN support are present

inlineImageExists() public méthode

Check if an inline attachment is present.
public inlineImageExists ( ) : boolean
Résultat boolean

isError() public méthode

Check if an error occurred.
public isError ( ) : boolean
Résultat boolean True if an error did occur.

isHTML() public méthode

Sets message type to HTML or plain.
public isHTML ( boolean $isHtml = true ) : void
$isHtml boolean True for HTML mode.
Résultat void

isMail() public méthode

Send messages using PHP's mail() function.
public isMail ( ) : void
Résultat void

isQmail() public méthode

Send messages using qmail.
public isQmail ( ) : void
Résultat void

isSMTP() public méthode

Send messages using SMTP.
public isSMTP ( ) : void
Résultat void

isSendmail() public méthode

Send messages using $Sendmail.
public isSendmail ( ) : void
Résultat void

lang() protected méthode

Get an error message in the current language.
protected lang ( string $key ) : string
$key string
Résultat string

mailSend() protected méthode

Send mail using the PHP mail() function.
protected mailSend ( string $header, string $body ) : boolean
$header string The message headers
$body string The message body
Résultat boolean

mb_pathinfo() public static méthode

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
Résultat string | array

msgHTML() public méthode

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()
Résultat string $message The transformed message Body

normalizeBreaks() public static méthode

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
Résultat string

parseAddresses() public méthode

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
Résultat array

postSend() public méthode

Send the email via the selected mechanism
public postSend ( ) : boolean
Résultat boolean

preSend() public méthode

Prepare a message for sending.
public preSend ( ) : boolean
Résultat boolean

punyencodeAddress() public méthode

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)
See also: PHPMailer::$CharSet
public punyencodeAddress ( string $address ) : string
$address string The email address to convert
Résultat string The encoded address in ASCII form

rfcDate() public static méthode

Return an RFC 822 formatted date.
public static rfcDate ( ) : string
Résultat string

secureHeader() public méthode

Strip newlines to prevent header injection.
public secureHeader ( string $str ) : string
$str string
Résultat string

send() public méthode

Uses the sending method specified by $Mailer.
public send ( ) : boolean
Résultat boolean false on error - See the ErrorInfo property for details of the error.

sendmailSend() protected méthode

Send mail using the $Sendmail program.
See also: PHPMailer::$Sendmail
protected sendmailSend ( string $header, string $body ) : boolean
$header string The message headers
$body string The message body
Résultat boolean

serverHostname() protected méthode

Returns 'localhost.localdomain' if unknown.
protected serverHostname ( ) : string
Résultat string

set() public méthode

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
Résultat boolean

setError() protected méthode

Add an error message to the error container.
protected setError ( string $msg ) : void
$msg string
Résultat void

setFrom() public méthode

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
Résultat boolean

setLanguage() public méthode

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)
Résultat boolean

setMessageType() protected méthode

PHPMailer only supports some preset message types, not arbitrary MIME structures.
protected setMessageType ( ) : void
Résultat void

setWordWrap() public méthode

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
Résultat void

sign() public méthode

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() public méthode

Close the active SMTP session if one exists.
public smtpClose ( ) : void
Résultat void

smtpConnect() public méthode

Returns false if the operation failed.
public smtpConnect ( array $options = null ) : boolean
$options array An array of options compatible with stream_context_create()
Résultat boolean

smtpSend() protected méthode

Returns false if there is a bad MAIL FROM, RCPT, or DATA input. Uses the PHPMailerSMTP class by default.
See also: PHPMailer::getSMTPInstance() to use a different class.
protected smtpSend ( string $header, string $body ) : boolean
$header string The message headers
$body string The message body
Résultat boolean

textLine() public méthode

Return a formatted mail line.
public textLine ( string $value ) : string
$value string
Résultat string

utf8CharBoundary() public méthode

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
Résultat integer

validateAddress() public static méthode

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.
Résultat boolean

wrapText() public méthode

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
Résultat string

Property Details

$AllowEmpty public_oe property

Whether to allow sending messages with an empty body.
public bool $AllowEmpty
Résultat boolean

$AltBody public_oe property

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
Résultat string

$AuthType public_oe property

Options are CRAM-MD5, LOGIN, PLAIN, NTLM, XOAUTH2, attempted in that order if not specified
public string $AuthType
Résultat string

$Body public_oe property

If HTML then call isHTML(true).
public string $Body
Résultat string

$CharSet public_oe property

The character set of the message.
public string $CharSet
Résultat string

$ConfirmReadingTo public_oe property

The email address that a reading confirmation should be sent to, also known as read receipt.
public string $ConfirmReadingTo
Résultat string

$ContentType public_oe property

The MIME Content-type of the message.
public string $ContentType
Résultat string

$CustomHeader protected_oe property

The array of custom headers.
protected array $CustomHeader
Résultat array

$DKIM_domain public_oe property

DKIM signing domain name.
public string $DKIM_domain
Résultat string

$DKIM_identity public_oe property

Usually the email address used as the source of the email.
public string $DKIM_identity
Résultat string

$DKIM_passphrase public_oe property

Used if your key is encrypted.
public string $DKIM_passphrase
Résultat string

$DKIM_private public_oe property

DKIM private key file path.
public string $DKIM_private
Résultat string

$DKIM_private_string public_oe property

If set, takes precedence over $DKIM_private.
public string $DKIM_private_string
Résultat string

$DKIM_selector public_oe property

DKIM selector.
public string $DKIM_selector
Résultat string

$Debugoutput public_oe property

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";};
See also: SMTP::$Debugoutput
public string|callable $Debugoutput
Résultat string | callable

$Encoding public_oe property

Options: "8bit", "7bit", "binary", "base64", and "quoted-printable".
public string $Encoding
Résultat string

$ErrorInfo public_oe property

Holds the most recent mailer error message.
public string $ErrorInfo
Résultat string

$From public_oe property

The From email address for the message.
public string $From
Résultat string

$FromName public_oe property

The From name of the message.
public string $FromName
Résultat string

$Helo public_oe property

Default is $Hostname. If $Hostname is empty, PHPMailer attempts to find one with the same method described above for $Hostname.
See also: PHPMailer::$Hostname
public string $Helo
Résultat string

$Host public_oe property

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
Résultat string

$Hostname public_oe property

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
Résultat string

$Ical public_oe property

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
Résultat string

$LE public_oe property

The default line ending.
public string $LE
Résultat string

$MIMEBody protected_oe property

The complete compiled MIME message body.
protected string $MIMEBody
Résultat string

$MIMEHeader protected_oe property

The complete compiled MIME message headers.
protected string $MIMEHeader
Résultat string

$Mailer public_oe property

Options: "mail", "sendmail", or "smtp".
public string $Mailer
Résultat string

$MessageDate public_oe property

If empty, the current date will be added.
public string $MessageDate
Résultat string

$MessageID public_oe property

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.
See also: https://tools.ietf.org/html/rfc5322#section-3.6.4
public string $MessageID
Résultat string

$Password public_oe property

SMTP password.
public string $Password
Résultat string

$PluginDir public_oe property

Useful if the SMTP class is not in the PHP include path.
Deprecation: Should not be needed now there is an autoloader.
public string $PluginDir
Résultat string

$Port public_oe property

The default SMTP server port.
public int $Port
Résultat integer

$Priority public_oe property

Options: null (default), 1 = High, 3 = Normal, 5 = low. When null, the header is not set at all.
public int $Priority
Résultat integer

$Realm public_oe property

Used for NTLM auth
public string $Realm
Résultat string

$RecipientsQueue protected_oe property

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.
See also: PHPMailer::$to @see PHPMailer::$cc @see PHPMailer::$bcc
See also: PHPMailer::$all_recipients
protected array $RecipientsQueue
Résultat array

$ReplyTo protected_oe property

The array of reply-to names and addresses.
protected array $ReplyTo
Résultat array

$ReplyToQueue protected_oe property

In send(), valid and non duplicate entries are moved to $ReplyTo. This array is used only for addresses with IDN.
See also: PHPMailer::$ReplyTo
protected array $ReplyToQueue
Résultat array

$ReturnPath public_oe property

If empty, it will be set to either From or Sender.
Deprecation: 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
Résultat string

$SMTPAuth public_oe property

Uses the Username and Password properties.
See also: PHPMailer::$Username
See also: PHPMailer::$Password
public bool $SMTPAuth
Résultat boolean

$SMTPAutoTLS public_oe property

Be aware that in PHP >= 5.6 this requires that the server's certificates are valid.
public bool $SMTPAutoTLS
Résultat boolean

$SMTPDebug public_oe property

Debug output level. Options: * 0 No output * 1 Commands * 2 Data and commands * 3 As 2 plus connection status * 4 Low-level data output
See also: SMTP::$do_debug
public int $SMTPDebug
Résultat integer

$SMTPKeepAlive public_oe property

If this is set to true then to close the connection requires an explicit call to smtpClose().
public bool $SMTPKeepAlive
Résultat boolean

$SMTPOptions public_oe property

Options array passed to stream_context_create when connecting via SMTP.
public array $SMTPOptions
Résultat array

$SMTPSecure public_oe property

Options: '', 'ssl' or 'tls'
public string $SMTPSecure
Résultat string

$Sender public_oe property

If not empty, will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.
public string $Sender
Résultat string

$Sendmail public_oe property

The path to the sendmail program.
public string $Sendmail
Résultat string

$SingleTo public_oe property

Only supported in mail and sendmail transports, not in SMTP.
public bool $SingleTo
Résultat boolean

$SingleToArray public_oe property

Storage for addresses when SingleTo is enabled.
public array $SingleToArray
Résultat array

$Subject public_oe property

The Subject of the message.
public string $Subject
Résultat string

$Timeout public_oe property

Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2
public int $Timeout
Résultat integer

$UseSendmailOptions public_oe property

One which supports sendmail's "-oi -f" options.
public bool $UseSendmailOptions
Résultat boolean

$Username public_oe property

SMTP username.
public string $Username
Résultat string

$Version public_oe property

The PHPMailer Version number.
public string $Version
Résultat string

$WordWrap public_oe property

Set to 0 to not wrap. A useful value here is 78, for RFC2822 section 2.1.1 compliance.
public int $WordWrap
Résultat integer

$Workstation public_oe property

Used for NTLM auth
public string $Workstation
Résultat string

$XMailer public_oe property

Options: An empty string for PHPMailer default, whitespace for none, or a string to use
public string $XMailer
Résultat string

$action_function public_oe property

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
Résultat string

$all_recipients protected_oe property

Includes all of $to, $cc, $bcc
See also: PHPMailer::$to @see PHPMailer::$cc @see PHPMailer::$bcc
protected array $all_recipients
Résultat array

$attachment protected_oe property

The array of attachments.
protected array $attachment
Résultat array

$bcc protected_oe property

The array of 'bcc' names and addresses.
protected array $bcc
Résultat array

$boundary protected_oe property

The array of MIME boundary strings.
protected array $boundary
Résultat array

$cc protected_oe property

The array of 'cc' names and addresses.
protected array $cc
Résultat array

$do_verp public_oe property

Only applicable when sending via SMTP.
public bool $do_verp
Résultat boolean

$error_count protected_oe property

The number of errors encountered.
protected int $error_count
Résultat integer

$exceptions protected_oe property

Whether to throw exceptions for errors.
protected bool $exceptions
Résultat boolean

$language protected_oe property

The array of available languages.
protected array $language
Résultat array

$lastMessageID protected_oe property

The most recent Message-ID (including angular brackets).
protected string $lastMessageID
Résultat string

$mailHeader protected_oe property

Extra headers that createHeader() doesn't fold in.
protected string $mailHeader
Résultat string

$message_type protected_oe property

The message's MIME type.
protected string $message_type
Résultat string

$sign_cert_file protected_oe property

The S/MIME certificate file path.
protected string $sign_cert_file
Résultat string

$sign_extracerts_file protected_oe property

The optional S/MIME extra certificates ("CA Chain") file path.
protected string $sign_extracerts_file
Résultat string

$sign_key_file protected_oe property

The S/MIME key file path.
protected string $sign_key_file
Résultat string

$sign_key_pass protected_oe property

Used only if the key is encrypted.
protected string $sign_key_pass
Résultat string

$smtp protected_oe property

An instance of the SMTP sender class.
protected SMTP $smtp
Résultat SMTP

$to protected_oe property

The array of 'to' names and addresses.
protected array $to
Résultat array

$uniqueid protected_oe property

Unique ID used for message ID and boundaries.
protected string $uniqueid
Résultat string

$validator public_oe static_oe property

May be a callable to inject your own validator, but there are several built-in validators.
See also: PHPMailer::validateAddress()
public static string|callable $validator
Résultat string | callable