PHPMailer
class PHPMailer
Constants
STOP_MESSAGE |
|
STOP_CONTINUE |
|
STOP_CRITICAL |
|
Properties
int | $Priority | Email priority (1 = High, 3 = Normal, 5 = low). | |
string | $CharSet | Sets the CharSet of the message. | |
string | $ContentType | Sets the Content-type of the message. | |
string | $Encoding | Sets the Encoding of the message. Options for this are "8bit", "7bit", "binary", "base64", and "quoted-printable". | |
string | $ErrorInfo | Holds the most recent mailer error message. | |
string | $From | Sets the From email address for the message. | |
string | $FromName | Sets the From name of the message. | |
string | $Sender | Sets the Sender email (Return-Path) of the message. If not empty, will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode. | |
string | $Subject | Sets the Subject of the message. | |
string | $Body | Sets the Body of the message. This can be either an HTML or text body. | |
string | $AltBody | Sets the text-only body of the message. This automatically sets the email to multipart/alternative. This body can be read by mail clients that do not have HTML email capability such as mutt. Clients that can read HTML will view the normal Body. | |
int | $WordWrap | Sets word wrapping on the body of the message to a given number of characters. | |
string | $Mailer | Method to send mail: ("mail", "sendmail", or "smtp"). | |
string | $Sendmail | Sets the path of the sendmail program. | |
string | $PluginDir | Path to PHPMailer plugins. Useful if the SMTP class is in a different directory than the PHP include path. | |
string | $ConfirmReadingTo | Sets the email address that a reading confirmation will be sent. | |
string | $Hostname | Sets the hostname to use in Message-Id and Received headers and as default HELO string. If empty, the value returned by SERVER_NAME is used or 'localhost.localdomain'. | |
string | $MessageID | Sets the message ID to be used in the Message-Id header. | |
string | $Host | Sets the SMTP hosts. All hosts must be separated by a semicolon. 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"). | |
int | $Port | Sets the default SMTP server port. | |
string | $Helo | Sets the SMTP HELO of the message (Default is $Hostname). | |
string | $SMTPSecure | Sets connection prefix. | |
bool | $SMTPAuth | Sets SMTP authentication. Utilizes the Username and Password variables. | |
string | $Username | Sets SMTP username. | |
string | $Password | Sets SMTP password. | |
int | $Timeout | Sets the SMTP server timeout in seconds. | |
bool | $SMTPDebug | Sets SMTP class debugging on or off. | |
bool | $SMTPKeepAlive | Prevents the SMTP connection from being closed after each mail sending. If this is set to true then to close the connection requires an explicit call to SmtpClose(). | |
bool | $SingleTo | Provides the ability to have the TO field process individual emails, instead of sending to entire TO addresses | |
bool | $SingleToArray | If SingleTo is true, this provides the array to hold the email addresses | |
string | $LE | Provides the ability to change the line ending | |
string | $DKIM_selector | Used with DKIM DNS Resource Record | |
string | $DKIM_identity | Used with DKIM DNS Resource Record optional, in format of email address 'you@yourdomain.com' | |
string | $DKIM_domain | Used with DKIM DNS Resource Record optional, in format of email address 'you@yourdomain.com' | |
string | $DKIM_private | Used with DKIM DNS Resource Record optional, in format of email address 'you@yourdomain.com' | |
string | $action_function | Callback Action function name the function that handles the result of the send email action. Parameters: bool $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 | $Version | Sets the PHPMailer Version number |
Methods
Constructor
Sets message type to HTML.
Sets Mailer to send message using SMTP.
Sets Mailer to send message using PHP mail() function.
Sets Mailer to send message using the $Sendmail program.
Sets Mailer to send message using the qmail MTA.
Adds a "To" address.
Adds a "Cc" address.
Adds a "Bcc" address.
Adds a "Reply-to" address.
Set the From and FromName properties
Check that a string looks roughly like an email address should Static so it can be used without instantiation Tries to use PHP built-in validator in the filter extension (from PHP 5.2), falls back to a reasonably competent regex validator Conforms approximately to RFC2822
Creates message and assigns Mailer. If the message is not sent successfully then it returns false. Use the ErrorInfo variable to view description of the error.
Initiates a connection to an SMTP server.
Closes the active SMTP session if one exists.
Sets the language for all class error messages.
Return the current array of language strings
Creates recipient headers.
Formats an address correctly.
Wraps message for use with mailers that do not automatically perform wrapping and for quoted-printable.
Finds last character boundary prior to maxLength in a utf-8 quoted (printable) encoded string.
Set the body wrapping.
Assembles message header.
Returns the message MIME.
Assembles the message body. Returns an empty string on failure.
Returns a formatted header line.
Returns a formatted mail line.
Adds an attachment from a path on the filesystem.
Return the current array of attachments
Encodes string to requested format.
Encode a header string to best (shortest) of Q, B, quoted or none.
Checks if a string contains multibyte characters.
Correctly encodes and wraps long multibyte strings for mail headers without breaking lines within a character.
Encode string to quoted-printable.
Encode string to RFC2045 (6.7) quoted-printable format Uses a PHP5 stream filter to do the encoding about 64x faster than the old version Also results in same content as you started with after decoding
Encode string to q encoding.
Adds a string or binary attachment (non-filesystem) to the list.
Adds an embedded attachment. This can include images, sounds, and just about any other document. Make sure to set the $type to an image type. For JPEG images use "image/jpeg" and for GIF images use "image/gif".
Returns true if an inline attachment is present.
Clears all recipients assigned in the TO array. Returns void.
Clears all recipients assigned in the CC array. Returns void.
Clears all recipients assigned in the BCC array. Returns void.
Clears all recipients assigned in the ReplyTo array. Returns void.
Clears all recipients assigned in the TO, CC and BCC array. Returns void.
Clears all previously set filesystem, string, and binary attachments. Returns void.
Clears all custom headers. Returns void.
Returns the proper RFC 822 formatted date.
Returns true if an error occurred.
Adds a custom header.
Evaluates the message and returns modifications for inline images and backgrounds
Gets the MIME type of the embedded or inline image
Set (or reset) Class Objects (variables)
Strips newlines to prevent header injection.
Set the private key file and password to sign the message.
Set the private key file and password to sign the message.
Generate DKIM signature
Generate DKIM Canonicalization Header
Generate DKIM Canonicalization Body
Create the DKIM header, body, as new header
Details
at line 342
__construct(boolean $exceptions = false)
Constructor
at line 351
void
IsHTML(bool $ishtml = true)
Sets message type to HTML.
at line 363
void
IsSMTP()
Sets Mailer to send message using SMTP.
at line 371
void
IsMail()
Sets Mailer to send message using PHP mail() function.
at line 379
void
IsSendmail()
Sets Mailer to send message using the $Sendmail program.
at line 390
void
IsQmail()
Sets Mailer to send message using the qmail MTA.
at line 407
boolean
AddAddress(string $address, string $name = '')
Adds a "To" address.
at line 418
boolean
AddCC(string $address, string $name = '')
Adds a "Cc" address.
Note: this function works with the SMTP mailer on win32, not with the "mail" mailer.
at line 429
boolean
AddBCC(string $address, string $name = '')
Adds a "Bcc" address.
Note: this function works with the SMTP mailer on win32, not with the "mail" mailer.
at line 439
boolean
AddReplyTo(string $address, string $name = '')
Adds a "Reply-to" address.
at line 488
boolean
SetFrom($address, $name = '', $auto = 1)
Set the From and FromName properties
at line 523
static boolean
ValidateAddress(string $address)
Check that a string looks roughly like an email address should Static so it can be used without instantiation Tries to use PHP built-in validator in the filter extension (from PHP 5.2), falls back to a reasonably competent regex validator Conforms approximately to RFC2822
at line 545
bool
Send()
Creates message and assigns Mailer. If the message is not sent successfully then it returns false. Use the ErrorInfo variable to view description of the error.
at line 797
bool
SmtpConnect()
Initiates a connection to an SMTP server.
Returns false if the operation failed.
at line 859
void
SmtpClose()
Closes the active SMTP session if one exists.
at line 875
SetLanguage(string $langcode = 'en', string $lang_path = 'language/')
Sets the language for all class error messages.
Returns false if it cannot load the language file. The default language is English.
at line 909
array
GetTranslations()
Return the current array of language strings
at line 922
string
AddrAppend($type, $addr)
Creates recipient headers.
at line 939
string
AddrFormat($addr)
Formats an address correctly.
at line 957
string
WrapText(string $message, integer $length, boolean $qp_mode = false)
Wraps message for use with mailers that do not automatically perform wrapping and for quoted-printable.
Original written by philippe.
at line 1039
int
UTF8CharBoundary(string $encodedText, int $maxLength)
Finds last character boundary prior to maxLength in a utf-8 quoted (printable) encoded string.
Original written by Colin Brown.
at line 1077
void
SetWordWrap()
Set the body wrapping.
at line 1098
string
CreateHeader()
Assembles message header.
at line 1181
string
GetMailMIME()
Returns the message MIME.
at line 1215
string
CreateBody()
Assembles the message body. Returns an empty string on failure.
at line 1342
string
HeaderLine($name, $value)
Returns a formatted header line.
at line 1351
string
TextLine($value)
Returns a formatted mail line.
at line 1369
bool
AddAttachment(string $path, string $name = '', string $encoding = 'base64', string $type = 'application/octet-stream')
Adds an attachment from a path on the filesystem.
Returns false if the file could not be found or accessed.
at line 1407
array
GetAttachments()
Return the current array of attachments
at line 1516
string
EncodeString(string $str, string $encoding = 'base64')
Encodes string to requested format.
Returns an empty string on failure.
at line 1547
string
EncodeHeader($str, $position = 'text')
Encode a header string to best (shortest) of Q, B, quoted or none.
at line 1608
bool
HasMultiBytes(string $str)
Checks if a string contains multibyte characters.
at line 1624
string
Base64EncodeWrapMB(string $str)
Correctly encodes and wraps long multibyte strings for mail headers without breaking lines within a character.
Adapted from a function by paravoid at http://uk.php.net/manual/en/function.mb-encode-mimeheader.php
at line 1664
string
EncodeQPphp($input = '', $line_max = 76, $space_conv = false)
Encode string to quoted-printable.
Only uses standard PHP, slow, but will always work
at line 1717
string
EncodeQP(string $string, integer $line_max = 76, boolean $space_conv = false)
Encode string to RFC2045 (6.7) quoted-printable format Uses a PHP5 stream filter to do the encoding about 64x faster than the old version Also results in same content as you started with after decoding
at line 1746
string
EncodeQ(string $str, string $position = 'text')
Encode string to q encoding.
at line 1781
void
AddStringAttachment(string $string, string $filename, string $encoding = 'base64', string $type = 'application/octet-stream')
Adds a string or binary attachment (non-filesystem) to the list.
This method can be used to attach ascii or binary data, such as a BLOB record from a database.
at line 1808
bool
AddEmbeddedImage(string $path, string $cid, string $name = '', string $encoding = 'base64', string $type = 'application/octet-stream')
Adds an embedded attachment. This can include images, sounds, and just about any other document. Make sure to set the $type to an image type. For JPEG images use "image/jpeg" and for GIF images use "image/gif".
at line 1840
bool
InlineImageExists()
Returns true if an inline attachment is present.
at line 1857
void
ClearAddresses()
Clears all recipients assigned in the TO array. Returns void.
at line 1868
void
ClearCCs()
Clears all recipients assigned in the CC array. Returns void.
at line 1879
void
ClearBCCs()
Clears all recipients assigned in the BCC array. Returns void.
at line 1890
void
ClearReplyTos()
Clears all recipients assigned in the ReplyTo array. Returns void.
at line 1899
void
ClearAllRecipients()
Clears all recipients assigned in the TO, CC and BCC array. Returns void.
at line 1911
void
ClearAttachments()
Clears all previously set filesystem, string, and binary attachments. Returns void.
at line 1919
void
ClearCustomHeaders()
Clears all custom headers. Returns void.
at line 1949
static string
RFCDate()
Returns the proper RFC 822 formatted date.
at line 1998
bool
IsError()
Returns true if an error occurred.
at line 2019
void
AddCustomHeader($custom_header)
Adds a custom header.
at line 2028
$message
MsgHTML($message, $basedir = '')
Evaluates the message and returns modifications for inline images and backgrounds
at line 2066
static string
_mime_types(string $ext = '')
Gets the MIME type of the embedded or inline image
at line 2171
set(string $name, mixed $value = '')
Set (or reset) Class Objects (variables)
Usage Example: $page->set('X-Priority', '3');
at line 2193
string
SecureHeader(string $str)
Strips newlines to prevent header injection.
at line 2206
Sign($cert_filename, $key_filename, $key_pass)
Set the private key file and password to sign the message.
at line 2219
DKIM_QP($txt)
Set the private key file and password to sign the message.
at line 2239
DKIM_Sign(string $s)
Generate DKIM signature
at line 2257
DKIM_HeaderC(string $s)
Generate DKIM Canonicalization Header
at line 2276
DKIM_BodyC(string $body)
Generate DKIM Canonicalization Body
at line 2296
DKIM_Add(string $headers_line, string $subject, string $body)
Create the DKIM header, body, as new header