Property |
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 LOGIN (default), PLAIN, NTLM, CRAM-MD5, XOAUTH2 |
|
$Body |
string |
If HTML then call isHTML(true). |
|
$CharSet |
string |
The character set of the message. |
|
$ConfirmReadingTo |
string |
The email address that a reading confirmation should be sent to, also known as read receipt. |
|
$ContentType |
string |
The MIME Content-type of the message. |
|
$DKIM_domain |
string |
DKIM signing domain name. |
|
$DKIM_identity |
string |
Usually the email address used as the source of the email |
|
$DKIM_passphrase |
string |
Used if your key is encrypted. |
|
$DKIM_private |
string |
DKIM private key file path. |
|
$DKIM_selector |
string |
DKIM selector. |
|
$Debugoutput |
string | callable |
Options:
* echo Output plain-text as-is, appropriate for CLI
* html Output escaped, line breaks converted to , appropriate for browser output
* error_log Output to error log as configured in php.ini
By default PHPMailer will use echo if run from a cli or cli-server SAPI, html otherwise.
Alternatively, you can provide a callable expecting two params: a message string and the debug level:
$mail->Debugoutput = function($str, $level) {echo "debug level $level; message: $str";};
|
|
$Encoding |
string |
Options: "8bit", "7bit", "binary", "base64", and "quoted-printable". |
|
$ErrorInfo |
string |
Holds the most recent mailer error message. |
|
$From |
string |
The From email address for the message. |
|
$FromName |
string |
The From name of the message. |
|
$Helo |
string |
Default is $Hostname. If $Hostname is empty, PHPMailer attempts to find
one with the same method described above for $Hostname. |
|
$Host |
string |
Either a single hostname or multiple semicolon-delimited hostnames.
You can also specify a different port
for each host by using this format: [hostname:port]
(e.g. "smtp1.example.com:25;smtp2.example.com").
You can also specify encryption type, for example:
(e.g. "tls://smtp1.example.com:587;ssl://smtp2.example.com:465").
Hosts will be tried in order. |
|
$Hostname |
string |
If empty, PHPMailer attempts to find one with, in order,
$_SERVER['SERVER_NAME'], gethostname(), php_uname('n'), or the value
'localhost.localdomain'. |
|
$Ical |
string |
Only supported in simple alt or alt_inline message types
To generate iCal events, use the bundled extras/EasyPeasyICS.php class or iCalcreator |
|
$LE |
string |
The default line ending. |
|
$Mailer |
string |
Options: "mail", "sendmail", or "smtp". |
|
$MessageDate |
string |
If empty, the current date will be added. |
|
$MessageID |
string |
If empty, a unique id will be generated. |
|
$Password |
string |
SMTP password. |
|
$Port |
integer |
The default SMTP server port. |
|
$Priority |
integer |
Options: null (default), 1 = High, 3 = Normal, 5 = low.
When null, the header is not set at all. |
|
$SMTPAuth |
boolean |
Uses the Username and Password properties. |
|
$SMTPAutoTLS |
boolean |
Be aware that in PHP >= 5.6 this requires that the server's certificates are valid. |
|
$SMTPDebug |
integer |
Debug output level.
Options:
* 0 No output
* 1 Commands
* 2 Data and commands
* 3 As 2 plus connection status
* 4 Low-level data output |
|
$SMTPKeepAlive |
boolean |
If this is set to true then to close the connection
requires an explicit call to smtpClose(). |
|
$SMTPOptions |
array |
Options array passed to stream_context_create when connecting via SMTP. |
|
$SMTPSecure |
string |
Options: '', 'ssl' or 'tls' |
|
$Sender |
string |
If not empty, will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode. |
|
$Sendmail |
string |
The path to the sendmail program. |
|
$SingleTo |
boolean |
Only supported in mail and sendmail transports, not in SMTP. |
|
$Subject |
string |
The Subject of the message. |
|
$Timeout |
integer |
Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2 |
|
$UseSendmailOptions |
boolean |
One which supports sendmail's "-oi -f" options. |
|
$Username |
string |
SMTP username. |
|
$WordWrap |
integer |
Set to 0 to not wrap. A useful value here is 78, for RFC2822 section 2.1.1 compliance. |
|
$XMailer |
string |
Options: An empty string for PHPMailer default, whitespace for none, or a string to use |
|
$action_function |
string |
The function that handles the result of the send email action.
It is called out by send() for each email sent.
Value can be any php callable: http://www.php.net/is_callable
Parameters:
boolean $result result of the send action
string $to email address of the recipient
string $cc cc email addresses
string $bcc bcc email addresses
string $subject the subject
string $body the email body
string $from email address of sender |
|
$do_verp |
boolean |
Only applicable when sending via SMTP. |
|
$validator |
string | callable |
May be a callable to inject your own validator, but there are several built-in validators. |
|
Method |
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 ) : string |
Encode a string in quoted-printable format. |
|
encodeString ( string $str, string $encoding = 'base64' ) : string |
Encode a string in requested format. |
|
filenameToType ( string $filename ) : string |
Map a file name to a MIME type. |
|
fixEOL ( string $str ) : string |
Ensure consistent line endings in a string. |
|
getAllRecipientAddresses ( ) : array |
Allows for public read access to 'all_recipients' property. |
|
getAttachments ( ) : array |
Return the array of attachments. |
|
getBccAddresses ( ) : array |
Allows for public read access to 'bcc' property. |
|
getCcAddresses ( ) : array |
Allows for public read access to 'cc' property. |
|
getCustomHeaders ( ) : array |
Returns all custom headers. |
|
getLastMessageID ( ) : string |
Return the Message-ID header of the last email. |
|
getMailMIME ( ) : string |
Get the message MIME type headers. |
|
getOAuth ( ) : OAuth |
Get the OAuth instance. |
|
getReplyToAddresses ( ) : array |
Allows for public read access to 'ReplyTo' property. |
|
getSMTPInstance ( ) : SMTP |
Get an instance to use for SMTP operations. |
|
getSentMIMEMessage ( ) : string |
Returns the whole MIME message. |
|
getToAddresses ( ) : array |
Allows for public read access to 'to' property. |
|
getTranslations ( ) : array |
Get the array of strings for the current language. |
|
has8bitChars ( string $text ) : boolean |
Does a string contain any 8-bit chars (in any charset)? |
|
hasLineLongerThanMax ( string $str ) : boolean |
Detect if a string contains a line longer than the maximum line length allowed. |
|
hasMultiBytes ( string $str ) : boolean |
Check if a string contains multi-byte characters. |
|
headerLine ( string $name, string $value ) : string |
Format a header line. |
|
html2text ( string $html, boolean | callable $advanced = false ) : string |
Convert an HTML string into plain text. |
|
idnSupported ( ) : boolean |
Tells whether IDNs (Internationalized Domain Names) are supported or not. This requires the
"intl" and "mbstring" PHP extensions. |
|
inlineImageExists ( ) : boolean |
Check if an inline attachment is present. |
|
isError ( ) : boolean |
Check if an error occurred. |
|
isHTML ( boolean $isHtml = true ) : void |
Sets message type to HTML or plain. |
|
isMail ( ) : void |
Send messages using PHP's mail() function. |
|
isQmail ( ) : void |
Send messages using qmail. |
|
isSMTP ( ) : void |
Send messages using SMTP. |
|
isSendmail ( ) : void |
Send messages using $Sendmail. |
|
mb_pathinfo ( string $path, integer | string $options = null ) : string | array |
Multi-byte-safe pathinfo replacement. |
|
msgHTML ( string $message, string $basedir = '', boolean | callable $advanced = false ) : string |
Create a message from an HTML string. |
|
normalizeBreaks ( string $text, string $breaktype = "
" ) : string |
Normalize line breaks in a string. |
|
parseAddresses ( string $addrstr, boolean $useimap = true ) : array |
Parse and validate a string containing one or more RFC822-style comma-separated email addresses
of the form "display name " into an array of name/address pairs. |
|
postSend ( ) : boolean |
Actually send a message. |
|
preSend ( ) : boolean |
Prepare a message for sending. |
|
punyencodeAddress ( string $address ) : string |
Converts IDN in given email address to its ASCII form, also known as punycode, if possible. |
|
rfcDate ( ) : string |
Return an RFC 822 formatted date. |
|
secureHeader ( string $str ) : string |
Strip newlines to prevent header injection. |
|
send ( ) : boolean |
Create a message and send it. |
|
set ( string $name, mixed $value = '' ) : boolean |
Set or reset instance properties. |
|
setFrom ( string $address, string $name = '', boolean $auto = true ) : boolean |
Set the From and FromName properties. |
|
setLanguage ( string $langcode = 'en', string $lang_path = '' ) : boolean |
Set the language for error messages. |
|
setOAuth ( OAuth $oauth ) |
Set an OAuth instance. |
|
setWordWrap ( ) : void |
Apply word wrapping to the message body. |
|
sign ( string $cert_filename, string $key_filename, string $key_pass, string $extracerts_filename = '' ) |
Set the public and private key files and password for S/MIME signing. |
|
smtpClose ( ) : void |
Close the active SMTP session if one exists. |
|
smtpConnect ( array $options = [] ) : boolean |
Initiate a connection to an SMTP server. |
|
textLine ( string $value ) : string |
Return a formatted mail line. |
|
utf8CharBoundary ( string $encodedText, integer $maxLength ) : integer |
Find the last character boundary prior to $maxLength in a utf-8
quoted-printable encoded string. |
|
validateAddress ( string $address, string | callable $patternselect = null ) : boolean |
Check that a string looks like an email address. |
|
wrapText ( string $message, integer $length, boolean $qp_mode = false ) : string |
Word-wrap message. |
|
Method |
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. |
|
cidExists ( $cid ) : boolean |
Check if an embedded attachment is present with this cid. |
|
doCallback ( boolean $isSent, array $to, array $cc, array $bcc, string $subject, string $body, string $from ) |
Perform a callback. |
|
edebug ( string $str ) |
Output debugging info via user-defined method. |
|
encodeFile ( string $path, string $encoding = 'base64' ) : string |
Encode a file attachment in requested format. |
|
endBoundary ( string $boundary ) : string |
Return the end of a message boundary. |
|
getBoundary ( string $boundary, string $charSet, string $contentType, string $encoding ) : string |
Return the start of a message boundary. |
|
lang ( string $key ) : string |
Get an error message in the current language. |
|
mailSend ( string $header, string $body ) : boolean |
Send mail using the PHP mail() function. |
|
sendmailSend ( string $header, string $body ) : boolean |
Send mail using the $Sendmail program. |
|
serverHostname ( ) : string |
Get the server hostname. |
|
setError ( string $msg ) : void |
Add an error message to the error container. |
|
setMessageType ( ) : void |
Set the message type. |
|
smtpSend ( string $header, string $body ) : boolean |
Send mail via SMTP. |
|
html2text()
public method
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();
});
$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 |
return |
string |
|
$ContentType public_oe property
The MIME Content-type of the message.
public string $ContentType |
return |
string |
|
$DKIM_domain public_oe property
DKIM signing domain name.
public string $DKIM_domain |
return |
string |
|
$MIMEBody protected_oe property
The complete compiled MIME message body.
protected string $MIMEBody |
return |
string |
|