Class PHPMailer

Description

PHPMailer - PHP email creation and transport class.

Located in /class.phpmailer.php (line 27)


	
			
Direct descendents
Class Description
PHPMailerOAuth PHPMailerOAuth - PHPMailer subclass adding OAuth support.
Method Summary
static string filenameToType (string $filename)
static boolean hasLineLongerThanMax (string $str)
static string|array mb_pathinfo (string $path, [integer|string $options = null])
static string normalizeBreaks (string $text, [string $breaktype = "\r\n"])
static string rfcDate ()
static boolean validateAddress (string $address, [string|callable $patternselect = null])
static string _mime_types ([string $ext = ''])
PHPMailer __construct ([boolean $exceptions = null])
void __destruct ()
boolean addAddress (string $address, [string $name = ''])
boolean addAnAddress (string $kind, string $address, [string $name = ''])
boolean addAttachment (string $path, [string $name = ''], [string $encoding = 'base64'], [string $type = ''], [string $disposition = 'attachment'])
boolean addBCC (string $address, [string $name = ''])
boolean addCC (string $address, [string $name = ''])
void addCustomHeader (string $name, [string $value = null])
boolean addEmbeddedImage (string $path, string $cid, [string $name = ''], [string $encoding = 'base64'], [string $type = ''], [string $disposition = 'inline'])
boolean addOrEnqueueAnAddress (string $kind, string $address, string $name)
string addrAppend (string $type, array $addr)
boolean addReplyTo (string $address, [string $name = ''])
string addrFormat (array $addr)
void addStringAttachment (string $string, string $filename, [string $encoding = 'base64'], [string $type = ''], [string $disposition = 'attachment' ])
boolean addStringEmbeddedImage (string $string, string $cid, [string $name = ''], [string $encoding = 'base64'], [string $type = ''], [string $disposition = 'inline' ])
boolean alternativeExists ()
string attachAll (string $disposition_type, string $boundary)
boolean attachmentExists ()
string base64EncodeWrapMB (string $str, [string $linebreak = null])
void clearAddresses ()
void clearBCCs ()
void clearCCs ()
void clearQueuedAddresses (string $kind)
void clearReplyTos ()
string createBody ()
string createHeader ()
string DKIM_Add (string $headers_line, string $subject, string $body)
string DKIM_BodyC (string $body)
string DKIM_HeaderC (string $signHeader)
string DKIM_QP (string $txt)
string DKIM_Sign (string $signHeader)
void doCallback (boolean $isSent, array $to, array $cc, array $bcc, string $subject, string $body, string $from)
void edebug (string $str)
string encodeFile (string $path, [string $encoding = 'base64'])
string encodeHeader (string $str, [string $position = 'text'])
string encodeQ (string $str, [string $position = 'text'])
string encodeQP (string $string, [integer $line_max = 76])
string encodeQPphp (string $string, [integer $line_max = 76], [boolean $space_conv = false ])
string encodeString (string $str, [string $encoding = 'base64'])
string endBoundary (string $boundary)
string fixEOL (string $str)
string generateId ()
array getAttachments ()
array getBccAddresses ()
string getBoundary (string $boundary, string $charSet, string $contentType, string $encoding)
array getCcAddresses ()
array getCustomHeaders ()
string getLastMessageID ()
string getMailMIME ()
string getSentMIMEMessage ()
array getToAddresses ()
array getTranslations ()
boolean has8bitChars (string $text)
boolean hasMultiBytes (string $str)
string headerLine (string $name, string $value)
string html2text (string $html, [boolean|callable $advanced = false])
bool idnSupported ()
boolean inlineImageExists ()
boolean isError ()
void isHTML ([boolean $isHtml = true])
void isMail ()
bool isPermittedPath (string $path)
void isQmail ()
void isSendmail ()
boolean isShellSafe (string $string)
void isSMTP ()
string lang (string $key)
boolean mailSend (string $header, string $body)
string msgHTML (string $message, [string $basedir = ''], [boolean|callable $advanced = false])
array parseAddresses (string $addrstr, [bool $useimap = true])
boolean postSend ()
boolean preSend ()
string punyencodeAddress (string $address)
string secureHeader (string $str)
boolean send ()
boolean sendmailSend (string $header, string $body)
string serverHostname ()
boolean set (string $name, [mixed $value = ''])
void setError (string $msg)
boolean setFrom (string $address, [string $name = ''], [boolean $auto = true])
boolean setLanguage ([string $langcode = 'en'], [string $lang_path = ''])
void setMessageType ()
void setWordWrap ()
void sign (string $cert_filename, string $key_filename, string $key_pass, [string $extracerts_filename = ''])
void smtpClose ()
boolean smtpConnect ([array $options = null])
boolean smtpSend (string $header, string $body)
string textLine (string $value)
integer utf8CharBoundary (string $encodedText, integer $maxLength)
string wrapText (string $message, integer $length, [boolean $qp_mode = false])
Methods
static method filenameToType (line 3649)

Map a file name to a MIME type. Defaults to 'application/octet-stream', i.e..

arbitrary binary data.

static string filenameToType (string $filename)
  • string $filename: A file name or full path, does not need to exist as a file
static method hasLineLongerThanMax (line 3968)

Detect if a string contains a line longer than the maximum line length allowed.

static boolean hasLineLongerThanMax (string $str)
  • string $str
static method mb_pathinfo (line 3671)

Multi-byte-safe pathinfo replacement.

Drop-in replacement for pathinfo(), but multibyte-safe, cross-platform-safe, old-version-safe. Works similarly to the one in PHP >= 5.2.0

static string|array mb_pathinfo (string $path, [integer|string $options = null])
  • string $path: A filename or path, does not need to exist as a file
  • integer|string $options: Either a PATHINFO_* constant, or a string name to return only the specified piece, allows 'filename' to work on PHP < 5.2
static method normalizeBreaks (line 3753)

Normalize line breaks in a string.

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.

  • access: public
static string normalizeBreaks (string $text, [string $breaktype = "\r\n"])
  • string $text
  • string $breaktype: What kind of line break to use, defaults to CRLF
static method rfcDate (line 3294)

Return an RFC 822 formatted date.

  • access: public
static string rfcDate ()
static method validateAddress (line 1069)

Check that a string looks like an email address.

  • access: public
static boolean validateAddress (string $address, [string|callable $patternselect = null])
  • string $address: The email address to check
  • string|callable $patternselect: 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('user@example.com', 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.
static method _mime_types (line 3534)

Get the MIME type for a file extension.

  • return: MIME type of file.
  • access: public
static string _mime_types ([string $ext = ''])
  • string $ext: File extension
Constructor __construct (line 656)

Constructor.

PHPMailer __construct ([boolean $exceptions = null])
  • boolean $exceptions: Should we throw external exceptions?
Destructor __destruct (line 668)

Destructor.

void __destruct ()
addAddress (line 818)

Add a "To" address.

  • return: true on success, false if address already used or invalid in some way
boolean addAddress (string $address, [string $name = ''])
  • string $address: The email address to send to
  • string $name
addAnAddress (line 914)

Add an address to one of the recipient arrays or to the ReplyTo array.

Addresses that have been added already return false, but do not throw exceptions.

  • return: true on success, false if address already used or invalid in some way
  • throws: phpmailerException
  • access: protected
boolean addAnAddress (string $kind, string $address, [string $name = ''])
  • string $kind: One of 'to', 'cc', 'bcc', or 'ReplyTo'
  • string $address: The email address to send, resp. to reply to
  • string $name
addAttachment (line 2526)

Add an attachment from a path on the filesystem.

Never use a user-supplied path to a file! Returns false if the file could not be found or read. Explicitly *does not* support passing URLs; PHPMailer is not an HTTP client. If you need to do that, fetch the resource yourself and pass it in via a local file or string.

  • throws: phpmailerException
boolean addAttachment (string $path, [string $name = ''], [string $encoding = 'base64'], [string $type = ''], [string $disposition = 'attachment'])
  • string $path: Path to the attachment.
  • string $name: Overrides the attachment name.
  • string $encoding: File encoding (see $Encoding).
  • string $type: File extension (MIME) type.
  • string $disposition: Disposition to use
addBCC (line 842)

Add a "BCC" address.

  • return: true on success, false if address already used or invalid in some way
boolean addBCC (string $address, [string $name = ''])
  • string $address: The email address to send to
  • string $name
addCC (line 830)

Add a "CC" address.

  • return: true on success, false if address already used or invalid in some way
boolean addCC (string $address, [string $name = ''])
  • string $address: The email address to send to
  • string $name
addCustomHeader (line 3386)

Add a custom header.

$name value can be overloaded to contain both header name and value (name:value)

  • access: public
void addCustomHeader (string $name, [string $value = null])
  • string $name: Custom header name
  • string $value: Header value
addEmbeddedImage (line 3055)

Add an embedded (inline) attachment from a file.

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. Never use a user-supplied path to a file!

  • return: True on successfully adding an attachment
boolean addEmbeddedImage (string $path, string $cid, [string $name = ''], [string $encoding = 'base64'], [string $type = ''], [string $disposition = 'inline'])
  • string $path: Path to the attachment.
  • string $cid: Content ID of the attachment; Use this to reference the content when using an embedded image in HTML.
  • string $name: Overrides the attachment name.
  • string $encoding: File encoding (see $Encoding).
  • string $type: File MIME type.
  • string $disposition: Disposition to use
addOrEnqueueAnAddress (line 870)

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(). Addresses that have been added already return false, but do not throw exceptions.

  • return: true on success, false if address already used or invalid in some way
  • throws: phpmailerException
  • access: protected
boolean addOrEnqueueAnAddress (string $kind, string $address, string $name)
  • string $kind: One of 'to', 'cc', 'bcc', or 'ReplyTo'
  • string $address: The email address to send, resp. to reply to
  • string $name
addrAppend (line 1839)

Create recipient headers.

  • access: public
string addrAppend (string $type, array $addr)
  • string $type
  • array $addr: 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('joe@example.com', 'Joe User'), array('zoe@example.com', 'Zoe User'))
addReplyTo (line 853)

Add a "Reply-To" address.

  • return: true on success, false if address already used or invalid in some way
boolean addReplyTo (string $address, [string $name = ''])
  • string $address: The email address to reply to
  • string $name
addrFormat (line 1855)

Format an address for use in a message header.

  • access: public
string addrFormat (array $addr)
  • array $addr: A 2-element indexed array, element 0 containing an address, element 1 containing a name like array('joe@example.com', 'Joe User')
addStringAttachment (line 3014)

Add a string or binary attachment (non-filesystem).

This method can be used to attach ascii or binary data, such as a BLOB record from a database.

void addStringAttachment (string $string, string $filename, [string $encoding = 'base64'], [string $type = ''], [string $disposition = 'attachment' ])
  • string $string: String attachment data.
  • string $filename: Name of the attachment.
  • string $encoding: File encoding (see $Encoding).
  • string $type: File extension (MIME) type.
  • string $disposition: Disposition to use
addStringEmbeddedImage (line 3100)

Add an embedded stringified attachment.

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

  • return: True on successfully adding an attachment
boolean addStringEmbeddedImage (string $string, string $cid, [string $name = ''], [string $encoding = 'base64'], [string $type = ''], [string $disposition = 'inline' ])
  • string $string: The attachment binary data.
  • string $cid: Content ID of the attachment; Use this to reference the content when using an embedded image in HTML.
  • string $name
  • string $encoding: File encoding (see $Encoding).
  • string $type: MIME type.
  • string $disposition: Disposition to use
alternativeExists (line 3160)

Check if this message has an alternative body set.

boolean alternativeExists ()
attachAll (line 2582)

Attach all file, string, and binary attachments to the message.

Returns an empty string on failure.

  • access: protected
string attachAll (string $disposition_type, string $boundary)
  • string $disposition_type
  • string $boundary
attachmentExists (line 3146)

Check if an attachment (non-inline) is present.

boolean attachmentExists ()
base64EncodeWrapMB (line 2880)

Encode and wrap long multibyte strings for mail headers without breaking lines within a character.

Adapted from a function by paravoid

string base64EncodeWrapMB (string $str, [string $linebreak = null])
  • string $str: multi-byte text to wrap encode
  • string $linebreak: string to use as linefeed/end-of-line
clearAddresses (line 3185)

Clear all To recipients.

void clearAddresses ()
clearAllRecipients (line 3234)

Clear all recipient types.

void clearAllRecipients ()
clearAttachments (line 3247)

Clear all filesystem, string, and binary attachments.

void clearAttachments ()
clearBCCs (line 3211)

Clear all BCC recipients.

void clearBCCs ()
clearCCs (line 3198)

Clear all CC recipients.

void clearCCs ()
clearCustomHeaders (line 3256)

Clear all custom headers.

void clearCustomHeaders ()
clearQueuedAddresses (line 3171)

Clear queued addresses of given kind.

  • access: protected
void clearQueuedAddresses (string $kind)
  • string $kind: 'to', 'cc', or 'bcc'
clearReplyTos (line 3224)

Clear all ReplyTo recipients.

void clearReplyTos ()
createBody (line 2215)

Assemble the message body.

Returns an empty string on failure.

  • return: The assembled message body
  • throws: phpmailerException
  • access: public
string createBody ()
createHeader (line 2045)

Assemble message headers.

  • return: The assembled headers
  • access: public
string createHeader ()
DKIM_Add (line 3890)

Create the DKIM header and body in a new message header.

  • access: public
string DKIM_Add (string $headers_line, string $subject, string $body)
  • string $headers_line: Header lines
  • string $subject: Subject
  • string $body: Body
DKIM_BodyC (line 3867)

Generate a DKIM canonicalization body.

  • access: public
string DKIM_BodyC (string $body)
  • string $body: Message Body
DKIM_HeaderC (line 3847)

Generate a DKIM canonicalization header.

  • access: public
string DKIM_HeaderC (string $signHeader)
  • string $signHeader: Header
DKIM_QP (line 3780)

Quoted-Printable-encode a DKIM header.

  • access: public
string DKIM_QP (string $txt)
  • string $txt
DKIM_Sign (line 3801)

Generate a DKIM signature.

  • return: The DKIM signature value
  • throws: phpmailerException
  • access: public
string DKIM_Sign (string $signHeader)
  • string $signHeader
doCallback (line 4039)

Perform a callback.

void doCallback (boolean $isSent, array $to, array $cc, array $bcc, string $subject, string $body, string $from)
  • boolean $isSent
  • array $to
  • array $cc
  • array $bcc
  • string $subject
  • string $body
  • string $from
edebug (line 712)

Output debugging info via user-defined method.

Only generates output if SMTP debug output is enabled (@see SMTP::$do_debug).

  • see: PHPMailer::$Debugoutput @
  • see: PHPMailer::$SMTPDebug @
void edebug (string $str)
  • string $str
encodeFile (line 2707)

Encode a file attachment in requested format.

Returns an empty string on failure.

  • throws: phpmailerException
  • access: protected
string encodeFile (string $path, [string $encoding = 'base64'])
  • string $path: The full path to the file
  • string $encoding: The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable'
encodeHeader (line 2787)

Encode a header string optimally.

Picks shortest of Q, B, quoted-printable or none.

  • access: public
string encodeHeader (string $str, [string $position = 'text'])
  • string $str
  • string $position
encodeQ (line 2963)

Encode a string using Q encoding.

string encodeQ (string $str, [string $position = 'text'])
  • string $str: the text to encode
  • string $position: Where the text is going to be used, see the RFC for what that means
encodeQP (line 2922)

Encode a string in quoted-printable format.

According to RFC2045 section 6.7.

string encodeQP (string $string, [integer $line_max = 76])
  • string $string: The text to encode
  • integer $line_max: Number of chars allowed on a line before wrapping
encodeQPphp (line 2947)

Backward compatibility wrapper for an old QP encoding function that was removed.

  • see: PHPMailer::encodeQP() @
  • deprecated: Use encodeQP instead.
  • access: public
string encodeQPphp (string $string, [integer $line_max = 76], [boolean $space_conv = false ])
  • string $string
  • integer $line_max
  • boolean $space_conv
encodeString (line 2751)

Encode a string in requested format.

Returns an empty string on failure.

  • access: public
string encodeString (string $str, [string $encoding = 'base64'])
  • string $str: The text to encode
  • string $encoding: The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable'
endBoundary (line 2459)

Return the end of a message boundary.

  • access: protected
string endBoundary (string $boundary)
  • string $boundary
fixEOL (line 3366)

Ensure consistent line endings in a string.

Changes every end of line from CRLF, CR or LF to $this->LE.

  • access: public
string fixEOL (string $str)
  • string $str: String to fixEOL
generateId (line 2204)

Create unique ID

string generateId ()
getAllRecipientAddresses (line 4024)

Allows for public read access to 'all_recipients' property.

  • access: public
array getAllRecipientAddresses ()
getAttachments (line 2569)

Return the array of attachments.

array getAttachments ()
getBccAddresses (line 4002)

Allows for public read access to 'bcc' property.

  • access: public
array getBccAddresses ()
getBoundary (line 2429)

Return the start of a message boundary.

  • access: protected
string getBoundary (string $boundary, string $charSet, string $contentType, string $encoding)
  • string $boundary
  • string $charSet
  • string $contentType
  • string $encoding
getCcAddresses (line 3991)

Allows for public read access to 'cc' property.

  • access: public
array getCcAddresses ()
getCustomHeaders (line 3400)

Returns all custom headers.

array getCustomHeaders ()
getLastMessageID (line 1045)

Return the Message-ID header of the last email.

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.

string getLastMessageID ()
getMailMIME (line 2140)

Get the message MIME type headers.

  • access: public
string getMailMIME ()
getReplyToAddresses (line 4013)

Allows for public read access to 'ReplyTo' property.

  • access: public
array getReplyToAddresses ()
getSentMIMEMessage (line 2195)

Returns the whole MIME message.

Includes complete headers and body. Only valid post preSend().

  • see: PHPMailer::preSend() @
  • access: public
string getSentMIMEMessage ()
getSMTPInstance (line 1533)

Get an instance to use for SMTP operations.

Override this function to load your own SMTP implementation

SMTP getSMTPInstance ()
getToAddresses (line 3980)

Allows for public read access to 'to' property.

  • access: public
array getToAddresses ()
getTranslations (line 1824)

Get the array of strings for the current language.

array getTranslations ()
has8bitChars (line 2865)

Does a string contain any 8-bit chars (in any charset)?

boolean has8bitChars (string $text)
  • string $text
hasMultiBytes (line 2851)

Check if a string contains multi-byte characters.

  • access: public
boolean hasMultiBytes (string $str)
  • string $str: multi-byte text to wrap encode
headerLine (line 2496)

Format a header line.

  • access: public
string headerLine (string $name, string $value)
  • string $name
  • string $value
html2text (line 3515)

Convert an HTML string into plain text.

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(); });

string html2text (string $html, [boolean|callable $advanced = false])
  • string $html: The HTML text to convert
  • boolean|callable $advanced: Any boolean value to use the internal converter, or provide your own callable for custom conversion.
idnSupported (line 1165)

Tells whether IDNs (Internationalized Domain Names) are supported or not.

This requires the "intl" and "mbstring" PHP extensions.

  • return: "true" if required functions for IDN support are present
bool idnSupported ()
inlineImageExists (line 3132)

Check if an inline attachment is present.

  • access: public
boolean inlineImageExists ()
isError (line 3354)

Check if an error occurred.

  • return: True if an error did occur.
  • access: public
boolean isError ()
isHTML (line 753)

Sets message type to HTML or plain.

void isHTML ([boolean $isHtml = true])
  • boolean $isHtml: True for HTML mode.
isMail (line 775)

Send messages using PHP's mail() function.

void isMail ()
isPermittedPath (line 1475)

Check whether a file path is of a permitted type.

Used to reject URLs and phar files from functions that access local file paths, such as addAttachment.

bool isPermittedPath (string $path)
  • string $path: A relative or absolute path to a file.
isQmail (line 800)

Send messages using qmail.

void isQmail ()
isSendmail (line 784)

Send messages using $Sendmail.

void isSendmail ()
isShellSafe (line 1443)

Fix CVE-2016-10033 and CVE-2016-10045 by disallowing potentially unsafe shell characters.

Note that escapeshellarg and escapeshellcmd are inadequate for our purposes, especially on Windows.

boolean isShellSafe (string $string)
  • string $string: The string to be validated
isSMTP (line 766)

Send messages using SMTP.

void isSMTP ()
lang (line 3329)

Get an error message in the current language.

  • access: protected
string lang (string $key)
  • string $key
mailSend (line 1489)

Send mail using the PHP mail() function.

boolean mailSend (string $header, string $body)
  • string $header: The message headers
  • string $body: The message body
msgHTML (line 3421)

Create a message body from an HTML string.

Automatically inlines images and creates a plain-text version by converting the HTML, overwriting any existing values in Body and AltBody. Do not source $message content from user input! $basedir is prepended when handling relative URLs, e.g. <img src="/images/a.png"> and must not be empty will look for an image file in $basedir/images/a.png and convert it to inline. If you don't provide a $basedir, relative paths will be left untouched (and thus probably break in email) If you don't want to apply these transformations to your HTML, just set Body and AltBody directly.

  • return: $message The transformed message Body
  • access: public
string msgHTML (string $message, [string $basedir = ''], [boolean|callable $advanced = false])
  • string $message: HTML message string
  • string $basedir: Absolute path to a base directory to prepend to relative paths to images
  • boolean|callable $advanced: Whether to use the internal HTML to text converter or your own custom converter @see PHPMailer::html2text()
parseAddresses (line 959)

Parse and validate a string containing one or more RFC822-style comma-separated email addresses of the form "display name <address>" into an array of name/address pairs.

Uses the imap_rfc822_parse_adrlist function if the IMAP extension is available. Note that quotes in the name part are removed.

array parseAddresses (string $addrstr, [bool $useimap = true])
  • string $addrstr: The address list string
  • bool $useimap: Whether to use the IMAP extension to parse the list
postSend (line 1330)

Actually send a message.

Send the email via the selected mechanism

  • throws: phpmailerException
boolean postSend ()
preSend (line 1230)

Prepare a message for sending.

  • throws: phpmailerException
boolean preSend ()
punyencodeAddress (line 1182)

Converts IDN in given email address to its ASCII form, also known as punycode, if possible.

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)

  • return: The encoded address in ASCII form
  • see: PHPMailer::$CharSet @
string punyencodeAddress (string $address)
  • string $address: The email address to convert
secureHeader (line 3738)

Strip newlines to prevent header injection.

  • access: public
string secureHeader (string $str)
  • string $str
send (line 1208)

Create a message and send it.

Uses the sending method specified by $Mailer.

  • return: false on error - See the ErrorInfo property for details of the error.
  • throws: phpmailerException
boolean send ()
sendmailSend (line 1369)

Send mail using the $Sendmail program.

  • see: PHPMailer::$Sendmail @
  • throws: phpmailerException
  • access: protected
boolean sendmailSend (string $header, string $body)
  • string $header: The message headers
  • string $body: The message body
serverHostname (line 3308)

Get the server hostname.

Returns 'localhost.localdomain' if unknown.

  • access: protected
string serverHostname ()
set (line 3721)

Set or reset instance properties.

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';`

  • TODO: Should this not be using the __set() magic function?
  • access: public
boolean set (string $name, [mixed $value = ''])
  • string $name: The property name to set
  • mixed $value: The value to set the property to
setError (line 3267)

Add an error message to the error container.

  • access: protected
void setError (string $msg)
  • string $msg
setFrom (line 1012)

Set the From and FromName properties.

  • throws: phpmailerException
boolean setFrom (string $address, [string $name = ''], [boolean $auto = true])
  • string $address
  • string $name
  • boolean $auto: Whether to also set the Sender address, defaults to true
setLanguage (line 1757)

Set the language for error messages.

Returns false if it cannot load the language file. The default language is English.

  • access: public
boolean setLanguage ([string $langcode = 'en'], [string $lang_path = ''])
  • string $langcode: ISO 639-1 2-character language code (e.g. French is "fr")
  • string $lang_path: Path to the language file directory, with trailing separator (slash)
setMessageType (line 2470)

Set the message type.

PHPMailer only supports some preset message types, not arbitrary MIME structures.

  • access: protected
void setMessageType ()
setWordWrap (line 2021)

Apply word wrapping to the message body.

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.

  • access: public
void setWordWrap ()
sign (line 3766)

Set the public and private key files and password for S/MIME signing.

  • access: public
void sign (string $cert_filename, string $key_filename, string $key_pass, [string $extracerts_filename = ''])
  • string $cert_filename
  • string $key_filename
  • string $key_pass: Password for private key
  • string $extracerts_filename: Optional path to chain certificate
smtpClose (line 1738)

Close the active SMTP session if one exists.

void smtpClose ()
smtpConnect (line 1616)

Initiate a connection to an SMTP server.

Returns false if the operation failed.

  • throws: phpmailerException
  • access: public
  • uses: SMTP - @
boolean smtpConnect ([array $options = null])
  • array $options: An array of options compatible with stream_context_create()

Redefined in descendants as:
smtpSend (line 1553)

Send mail via SMTP.

Returns false if there is a bad MAIL FROM, RCPT, or DATA input. Uses the PHPMailerSMTP class by default.

  • see: PHPMailer::getSMTPInstance() to use a different class. @
  • throws: phpmailerException
  • access: protected
  • uses: SMTP - @
boolean smtpSend (string $header, string $body)
  • string $header: The message headers
  • string $body: The message body
textLine (line 2507)

Return a formatted mail line.

  • access: public
string textLine (string $value)
  • string $value
utf8CharBoundary (line 1976)

Find the last character boundary prior to $maxLength in a utf-8 quoted-printable encoded string.

Original written by Colin Brown.

  • access: public
integer utf8CharBoundary (string $encodedText, integer $maxLength)
  • string $encodedText: utf-8 QP text
  • integer $maxLength: Find the last character boundary prior to this length
wrapText (line 1877)

Word-wrap message.

For use with mailers that do not automatically perform wrapping and for quoted-printable encoded messages. Original written by philippe.

  • access: public
string wrapText (string $message, integer $length, [boolean $qp_mode = false])
  • string $message: The message to wrap
  • integer $length: The line length to wrap to
  • boolean $qp_mode: Whether to run in Quoted-Printable mode

Documentation generated on Sun, 28 Jul 2024 13:19:41 +0200 by phpDocumentor 1.4.4