Class PHPMailer

Description

PHPMailer - PHP email transport class

NOTE: Requires PHP version 5 or later

  • author: Marcus Bointon
  • author: Andy Prevost
  • version: $Id: class.phpmailer.php 447 2009-05-25 01:36:38Z codeworxtech $
  • copyright: 2004 - 2009 Andy Prevost
  • license: GNU Lesser General Public License

Located in /libs/PHPMailer/class.phpmailer.php (line 43)


	
			
Class Constant Summary
Variable Summary
 string $AltBody
 string $Body
 string $CharSet
 string $ContentType
 string $DKIM_domain
 string $DKIM_private
 string $Encoding
 string $ErrorInfo
 string $From
 string $FromName
 string $Helo
 string $Host
 string $Hostname
 mixed $language
 string $LE
 string $Mailer
 string $MessageID
 string $Password
 string $PluginDir
 int $Port
 int $Priority
 string $Sender
 string $Sendmail
 bool $SingleTo
 bool $SMTPAuth
 bool $SMTPDebug
 string $SMTPSecure
 string $Subject
 int $Timeout
 string $Username
 string $Version
 int $WordWrap
Method Summary
 static string RFCDate ()
 static boolean ValidateAddress (string $address)
 static string _mime_types ([string $ext = ''])
 PHPMailer __construct ([boolean $exceptions = false])
 boolean AddAddress (string $address, [string $name = ''])
 bool AddAttachment (string $path, [string $name = ''], [string $encoding = 'base64'], [string $type = 'application/octet-stream'])
 boolean AddBCC (string $address, [string $name = ''])
 boolean AddCC (string $address, [string $name = ''])
 void AddCustomHeader ( $custom_header)
 bool AddEmbeddedImage (string $path, string $cid, [string $name = ''], [string $encoding = 'base64'], [string $type = 'application/octet-stream'])
 string AddrAppend ( $type,  $addr)
 boolean AddReplyTo (string $address, [string $name = ''])
 string AddrFormat ( $addr)
 void AddStringAttachment (string $string, string $filename, [string $encoding = 'base64'], [string $type = 'application/octet-stream'])
 string Base64EncodeWrapMB (string $str)
 void ClearAddresses ()
 void ClearBCCs ()
 void ClearCCs ()
 void ClearReplyTos ()
 string CreateBody ()
 string CreateHeader ()
 void DKIM_Add (string $headers_line, string $subject, string $body)
 void DKIM_BodyC (string $body)
 void DKIM_HeaderC (string $s)
 void DKIM_QP ( $txt, string $key_filename, string $key_pass)
 void DKIM_Sign (string $s)
 void doCallback ( $isSent,  $to,  $cc,  $bcc,  $subject,  $body)
 string EncodeHeader ( $str, [ $position = 'text'])
 string EncodeQ (string $str, [string $position = 'text'])
 string EncodeQP (string $string, [integer $line_max = 76], [boolean $space_conv = false])
 string EncodeQPphp ([ $input = ''], [integer $line_max = 76], [ $space_conv = false], string $string)
 string EncodeString (string $str, [string $encoding = 'base64'])
 array GetAttachments ()
 string GetMailMIME ()
 array GetTranslations ()
 bool HasMultiBytes (string $str)
 string HeaderLine ( $name,  $value)
 bool IsError ()
 void IsHTML ([bool $ishtml = true])
 void IsMail ()
 void IsQmail ()
 void IsSendmail ()
 void IsSMTP ()
 bool MailSend (string $header, string $body)
 $message MsgHTML ( $message, [ $basedir = ''])
 string SecureHeader (string $str)
 bool Send ()
 bool SendmailSend (string $header, string $body)
 void set (string $name, [mixed $value = ''])
 void SetError ( $msg)
 boolean SetFrom (string $address, [string $name = ''], [ $auto = 1])
 void SetLanguage ([string $langcode = 'en'], [string $lang_path = 'language/'])
 void SetWordWrap ()
 void Sign ( $cert_filename, string $key_filename, string $key_pass)
 void SmtpClose ()
 bool SmtpConnect ()
 bool SmtpSend (string $header, string $body)
 string TextLine ( $value)
 int UTF8CharBoundary (string $encodedText, int $maxLength)
 string WrapText (string $message, integer $length, [boolean $qp_mode = false])
Variables
string $action_function = '' (line 297)

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

  • access: public
string $AltBody = '' (line 119)

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.

  • access: public
string $Body = '' (line 110)

Sets the Body of the message. This can be either an HTML or text body.

If HTML then run IsHTML(true).

  • access: public
string $CharSet = 'iso-8859-1' (line 59)

Sets the CharSet of the message.

  • access: public
string $ConfirmReadingTo = '' (line 151)

Sets the email address that a reading confirmation will be sent.

  • access: public
string $ContentType = 'text/plain' (line 65)

Sets the Content-type of the message.

  • access: public
string $DKIM_domain = '' (line 277)

Used with DKIM DNS Resource Record

optional, in format of email address 'you@yourdomain.com'

  • access: public
string $DKIM_identity = '' (line 270)

Used with DKIM DNS Resource Record

optional, in format of email address 'you@yourdomain.com'

  • access: public
string $DKIM_private = '' (line 284)

Used with DKIM DNS Resource Record

optional, in format of email address 'you@yourdomain.com'

  • access: public
string $DKIM_selector = 'phpmailer' (line 263)

Used with DKIM DNS Resource Record

  • access: public
string $Encoding = '8bit' (line 72)

Sets the Encoding of the message. Options for this are "8bit", "7bit", "binary", "base64", and "quoted-printable".

  • access: public
string $ErrorInfo = '' (line 78)

Holds the most recent mailer error message.

  • access: public
string $From = 'root@localhost' (line 84)

Sets the From email address for the message.

  • access: public
string $FromName = 'Root User' (line 90)

Sets the From name of the message.

  • access: public
string $Helo = '' (line 192)

Sets the SMTP HELO of the message (Default is $Hostname).

  • access: public
string $Host = 'localhost' (line 180)

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").

Hosts will be tried in order.

  • access: public
string $Hostname = '' (line 159)

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

  • access: public
mixed $language = array() (line 319)
  • access: protected
string $LE = "\n" (line 257)

Provides the ability to change the line ending

  • access: public
string $Mailer = 'mail' (line 132)

Method to send mail: ("mail", "sendmail", or "smtp").

  • access: public
string $MessageID = '' (line 166)

Sets the message ID to be used in the Message-Id header.

If empty, a unique id will be generated.

  • access: public
string $Password = '' (line 217)

Sets SMTP password.

  • access: public
string $PluginDir = '' (line 145)

Path to PHPMailer plugins. Useful if the SMTP class is in a different directory than the PHP include path.

  • access: public
int $Port = 25 (line 186)

Sets the default SMTP server port.

  • access: public
int $Priority = 3 (line 53)

Email priority (1 = High, 3 = Normal, 5 = low).

  • access: public
string $Sender = '' (line 97)

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.

  • access: public
string $Sendmail = '/usr/sbin/sendmail' (line 138)

Sets the path of the sendmail program.

  • access: public
bool $SingleTo = false (line 245)

Provides the ability to have the TO field process individual

emails, instead of sending to entire TO addresses

  • access: public
bool $SingleToArray = array() (line 251)

If SingleTo is true, this provides the array to hold the email addresses

  • access: public
bool $SMTPAuth = false (line 205)

Sets SMTP authentication. Utilizes the Username and Password variables.

  • access: public
bool $SMTPDebug = false (line 230)

Sets SMTP class debugging on or off.

  • access: public
bool $SMTPKeepAlive = false (line 238)

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().

  • access: public
string $SMTPSecure = '' (line 199)

Sets connection prefix.

Options are "", "ssl" or "tls"

  • access: public
string $Subject = '' (line 103)

Sets the Subject of the message.

  • access: public
int $Timeout = 10 (line 224)

Sets the SMTP server timeout in seconds.

This function will not work with the win32 version.

  • access: public
string $Username = '' (line 211)

Sets SMTP username.

  • access: public
string $Version = '5.1' (line 303)

Sets the PHPMailer Version number

  • access: public
int $WordWrap = 0 (line 126)

Sets word wrapping on the body of the message to a given number of characters.

  • access: public
Methods
static RFCDate (line 1924)

Returns the proper RFC 822 formatted date.

  • access: public
string RFCDate ()
static ValidateAddress (line 523)

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

boolean ValidateAddress (string $address)
  • string $address: The email address to check
static _mime_types (line 2041)

Gets the MIME type of the embedded or inline image

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

Constructor

  • access: public
PHPMailer __construct ([boolean $exceptions = false])
  • boolean $exceptions: Should we throw external exceptions?
AddAddress (line 407)

Adds a "To" address.

  • return: true on success, false if address already used
  • access: public
boolean AddAddress (string $address, [string $name = ''])
  • string $address
  • string $name
AddAttachment (line 1344)

Adds an attachment from a path on the filesystem.

Returns false if the file could not be found or accessed.

  • access: public
bool AddAttachment (string $path, [string $name = ''], [string $encoding = 'base64'], [string $type = 'application/octet-stream'])
  • string $path: Path to the attachment.
  • string $name: Overrides the attachment name.
  • string $encoding: File encoding (see $Encoding).
  • string $type: File extension (MIME) type.
AddBCC (line 429)

Adds a "Bcc" address.

Note: this function works with the SMTP mailer on win32, not with the "mail" mailer.

  • return: true on success, false if address already used
  • access: public
boolean AddBCC (string $address, [string $name = ''])
  • string $address
  • string $name
AddCC (line 418)

Adds a "Cc" address.

Note: this function works with the SMTP mailer on win32, not with the "mail" mailer.

  • return: true on success, false if address already used
  • access: public
boolean AddCC (string $address, [string $name = ''])
  • string $address
  • string $name
AddCustomHeader (line 1994)

Adds a custom header.

  • access: public
void AddCustomHeader ( $custom_header)
  • $custom_header
AddEmbeddedImage (line 1783)

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

  • access: public
bool AddEmbeddedImage (string $path, string $cid, [string $name = ''], [string $encoding = 'base64'], [string $type = 'application/octet-stream'])
  • string $path: Path to the attachment.
  • string $cid: Content ID of the attachment. Use this to identify the Id for accessing the image in an HTML form.
  • string $name: Overrides the attachment name.
  • string $encoding: File encoding (see $Encoding).
  • string $type: File extension (MIME) type.
AddrAppend (line 897)

Creates recipient headers.

  • access: public
string AddrAppend ( $type,  $addr)
  • $type
  • $addr
AddReplyTo (line 439)

Adds a "Reply-to" address.

  • access: public
boolean AddReplyTo (string $address, [string $name = ''])
  • string $address
  • string $name
AddrFormat (line 914)

Formats an address correctly.

  • access: public
string AddrFormat ( $addr)
  • $addr
AddStringAttachment (line 1756)

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.

  • access: public
void AddStringAttachment (string $string, string $filename, [string $encoding = 'base64'], [string $type = 'application/octet-stream'])
  • string $string: String attachment data.
  • string $filename: Name of the attachment.
  • string $encoding: File encoding (see $Encoding).
  • string $type: File extension (MIME) type.
Base64EncodeWrapMB (line 1599)

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

  • access: public
string Base64EncodeWrapMB (string $str)
  • string $str: multi-byte text to wrap encode
ClearAddresses (line 1832)

Clears all recipients assigned in the TO array. Returns void.

  • access: public
void ClearAddresses ()
ClearAllRecipients (line 1874)

Clears all recipients assigned in the TO, CC and BCC array. Returns void.

  • access: public
void ClearAllRecipients ()
ClearAttachments (line 1886)

Clears all previously set filesystem, string, and binary attachments. Returns void.

  • access: public
void ClearAttachments ()
ClearBCCs (line 1854)

Clears all recipients assigned in the BCC array. Returns void.

  • access: public
void ClearBCCs ()
ClearCCs (line 1843)

Clears all recipients assigned in the CC array. Returns void.

  • access: public
void ClearCCs ()
ClearCustomHeaders (line 1894)

Clears all custom headers. Returns void.

  • access: public
void ClearCustomHeaders ()
ClearReplyTos (line 1865)

Clears all recipients assigned in the ReplyTo array. Returns void.

  • access: public
void ClearReplyTos ()
CreateBody (line 1190)

Assembles the message body. Returns an empty string on failure.

  • return: The assembled message body
  • access: public
string CreateBody ()
CreateHeader (line 1073)

Assembles message header.

  • return: The assembled header
  • access: public
string CreateHeader ()
DKIM_Add (line 2271)

Create the DKIM header, body, as new header

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

Generate DKIM Canonicalization Body

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

Generate DKIM Canonicalization Header

  • access: public
void DKIM_HeaderC (string $s)
  • string $s: Header
DKIM_QP (line 2194)

Set the private key file and password to sign the message.

  • access: public
void DKIM_QP ( $txt, string $key_filename, string $key_pass)
  • string $key_filename: Parameter File Name
  • string $key_pass: Password for private key
  • $txt
DKIM_Sign (line 2214)

Generate DKIM signature

  • access: public
void DKIM_Sign (string $s)
  • string $s: Header
doCallback (line 2306)
  • access: protected
void doCallback ( $isSent,  $to,  $cc,  $bcc,  $subject,  $body)
  • $isSent
  • $to
  • $cc
  • $bcc
  • $subject
  • $body
EncodeHeader (line 1522)

Encode a header string to best (shortest) of Q, B, quoted or none.

  • access: public
string EncodeHeader ( $str, [ $position = 'text'])
  • $str
  • $position
EncodeQ (line 1721)

Encode string to 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 1692)

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

string EncodeQP (string $string, [integer $line_max = 76], [boolean $space_conv = false])
  • string $string: the text to encode
  • integer $line_max: Number of chars allowed on a line before wrapping
  • boolean $space_conv: Dummy param for compatibility with existing EncodeQP function
EncodeQPphp (line 1639)

Encode string to quoted-printable.

Only uses standard PHP, slow, but will always work

  • access: public
string EncodeQPphp ([ $input = ''], [integer $line_max = 76], [ $space_conv = false], string $string)
  • string $string: the text to encode
  • integer $line_max: Number of chars allowed on a line before wrapping
  • $input
  • $space_conv
EncodeString (line 1491)

Encodes string to 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'
GetAttachments (line 1382)

Return the current array of attachments

  • access: public
array GetAttachments ()
GetMailMIME (line 1156)

Returns the message MIME.

  • access: public
string GetMailMIME ()
GetTranslations (line 884)

Return the current array of language strings

  • access: public
array GetTranslations ()
HasMultiBytes (line 1583)

Checks if a string contains multibyte characters.

  • access: public
bool HasMultiBytes (string $str)
  • string $str: multi-byte text to wrap encode
HeaderLine (line 1317)

Returns a formatted header line.

  • access: public
string HeaderLine ( $name,  $value)
  • $name
  • $value
InlineImageExists (line 1815)

Returns true if an inline attachment is present.

  • access: public
bool InlineImageExists ()
IsError (line 1973)

Returns true if an error occurred.

  • access: public
bool IsError ()
IsHTML (line 351)

Sets message type to HTML.

  • access: public
void IsHTML ([bool $ishtml = true])
  • bool $ishtml
IsMail (line 371)

Sets Mailer to send message using PHP mail() function.

  • access: public
void IsMail ()
IsQmail (line 390)

Sets Mailer to send message using the qmail MTA.

  • access: public
void IsQmail ()
IsSendmail (line 379)

Sets Mailer to send message using the $Sendmail program.

  • access: public
void IsSendmail ()
IsSMTP (line 363)

Sets Mailer to send message using SMTP.

  • access: public
void IsSMTP ()
MailSend (line 644)

Sends mail using the PHP mail() function.

  • access: protected
bool MailSend (string $header, string $body)
  • string $header: The message headers
  • string $body: The message body
MsgHTML (line 2003)

Evaluates the message and returns modifications for inline images and backgrounds

  • access: public
$message MsgHTML ( $message, [ $basedir = ''])
  • $message
  • $basedir
SecureHeader (line 2168)

Strips newlines to prevent header injection.

  • access: public
string SecureHeader (string $str)
  • string $str: String
Send (line 545)

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.

  • access: public
bool Send ()
SendmailSend (line 598)

Sends mail using the $Sendmail program.

  • access: protected
bool SendmailSend (string $header, string $body)
  • string $header: The message headers
  • string $body: The message body
set (line 2146)

Set (or reset) Class Objects (variables)

Usage Example: $page->set('X-Priority', '3');

  • todo: Should this not be using __set() magic function?
  • access: public
void set (string $name, [mixed $value = ''])
  • string $name: Parameter Name
  • mixed $value: Parameter Value NOTE: will not work with arrays, there are no arrays to set/reset
SetError (line 1907)

Adds the error message to the error container.

  • access: protected
void SetError ( $msg)
  • $msg
SetFrom (line 488)

Set the From and FromName properties

  • access: public
boolean SetFrom (string $address, [string $name = ''], [ $auto = 1])
  • string $address
  • string $name
  • $auto
SetLanguage (line 850)

Sets the language for all class error messages.

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

  • access: public
void SetLanguage ([string $langcode = 'en'], [string $lang_path = 'language/'])
  • string $langcode: ISO 639-1 2-character language code (e.g. Portuguese: "br")
  • string $lang_path: Path to the language file directory
SetWordWrap (line 1052)

Set the body wrapping.

  • access: public
void SetWordWrap ()
Sign (line 2181)

Set the private key file and password to sign the message.

  • access: public
void Sign ( $cert_filename, string $key_filename, string $key_pass)
  • string $key_filename: Parameter File Name
  • string $key_pass: Password for private key
  • $cert_filename
SmtpClose (line 834)

Closes the active SMTP session if one exists.

  • access: public
void SmtpClose ()
SmtpConnect (line 772)

Initiates a connection to an SMTP server.

Returns false if the operation failed.

  • access: public
  • uses: SMTP
bool SmtpConnect ()
SmtpSend (line 701)

Sends mail via SMTP using PhpSMTP Returns false if there is a bad MAIL FROM, RCPT, or DATA input.

  • access: protected
  • uses: SMTP
bool SmtpSend (string $header, string $body)
  • string $header: The message headers
  • string $body: The message body
TextLine (line 1326)

Returns a formatted mail line.

  • access: public
string TextLine ( $value)
  • $value
UTF8CharBoundary (line 1014)

Finds last character boundary prior to maxLength in a utf-8 quoted (printable) encoded string.

Original written by Colin Brown.

  • access: public
int UTF8CharBoundary (string $encodedText, int $maxLength)
  • string $encodedText: utf-8 QP text
  • int $maxLength: find last character boundary prior to this length
WrapText (line 932)

Wraps message for use with mailers that do not automatically perform wrapping and for quoted-printable.

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
Class Constants
STOP_CONTINUE = 1 (line 331)
STOP_CRITICAL = 2 (line 332)
STOP_MESSAGE = 0 (line 330)

Documentation generated on Sun, 04 Apr 2010 22:43:35 +0200 by phpDocumentor 1.4.1