Class PHPMailer

Description

PHPMailer - PHP email transport class

NOTE: Requires PHP version 5 or later

  • license: GNU Lesser General Public License
  • version: $Id: class.phpmailer.php 254 2009-04-02 18:52:18Z codeworxtech $
  • copyright: 2004 - 2009 Andy Prevost
  • author: Andy Prevost
  • author: Marcus Bointon

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


	
			
Class Constant Summary
Variable Summary
string $AltBody
string $Body
string $CharSet
string $ContentType
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
int $WordWrap
Method Summary
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 (mixed $custom_header)
bool AddEmbeddedImage (string $path, string $cid, [string $name = ''], [string $encoding = 'base64'], [string $type = 'application/octet-stream'])
string AddrAppend (mixed $type, mixed $addr)
boolean AddReplyTo (string $address, [string $name = ''])
string AddrFormat (mixed $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 ()
string EncodeHeader (mixed $str, [mixed $position = 'text'])
string EncodeQ (string $str, [string $position = 'text'])
string EncodeQP (string $string, [integer $line_max = 76], [boolean $space_conv = false])
string EncodeQPphp ([mixed $input = ''], [integer $line_max = 76], [mixed $space_conv = false], string $string)
string EncodeString (string $str, [string $encoding = 'base64'])
array GetAttachments ()
string GetMailMIME ()
array GetTranslations ()
bool HasMultiBytes (string $str)
string HeaderLine (mixed $name, mixed $value)
bool IsError ()
void IsHTML ([bool $ishtml = true])
void IsMail ()
void IsQmail ()
void IsSendmail ()
void IsSMTP ()
bool MailSend (string $header, string $body)
$message MsgHTML (mixed $message, [mixed $basedir = ''])
string RFCDate ()
string SecureHeader (string $str)
bool Send ()
bool SendmailSend (string $header, string $body)
void set (string $name, [mixed $value = ''])
void SetError (mixed $msg)
boolean SetFrom (string $address, [string $name = ''])
void SetLanguage ([string $langcode = 'en'], [string $lang_path = 'language/'])
void SetWordWrap ()
void Sign (mixed $cert_filename, string $key_filename, string $key_pass)
void SmtpClose ()
bool SmtpConnect ()
bool SmtpSend (string $header, string $body)
string TextLine (mixed $value)
int UTF8CharBoundary (string $encodedText, int $maxLength)
boolean ValidateAddress (string $address)
string WrapText (string $message, integer $length, [boolean $qp_mode = false])
string _mime_types ([string $ext = ''])
Variables
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 $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 267)
  • access: protected
string $LE = "\n" (line 251)

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 $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
int $WordWrap = 0 (line 126)

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

  • access: public
Methods
Constructor __construct (line 291)

Constructor

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

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 1218)

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 378)

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 367)

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 1868)

Adds a custom header.

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

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 777)

Creates recipient headers.

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

Adds a "Reply-to" address.

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

Formats an address correctly.

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

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 1473)

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 1706)

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

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

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

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

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

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

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

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

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

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

Clears all custom headers. Returns void.

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

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

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

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

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

Assembles message header.

  • return: The assembled header
  • access: public
string CreateHeader ()
EncodeHeader (line 1396)

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

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

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 1566)

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 1513)

Encode string to quoted-printable.

Only uses standard PHP, slow, but will always work

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

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 1256)

Return the current array of attachments

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

Returns the message MIME.

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

Return the current array of language strings

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

Checks if a string contains multibyte characters.

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

Returns a formatted header line.

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

Returns true if an inline attachment is present.

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

Returns true if an error occurred.

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

Sets message type to HTML.

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

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

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

Sets Mailer to send message using the qmail MTA.

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

Sets Mailer to send message using the $Sendmail program.

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

Sets Mailer to send message using SMTP.

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

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 1877)

Evaluates the message and returns modifications for inline images and backgrounds

  • access: public
$message MsgHTML (mixed $message, [mixed $basedir = ''])
RFCDate (line 1798)

Returns the proper RFC 822 formatted date.

  • static:
  • access: public
string RFCDate ()
SecureHeader (line 2042)

Strips newlines to prevent header injection.

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

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 534)

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 2020)

Set (or reset) Class Objects (variables)

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

  • access: public
  • todo: Should this not be using __set() magic function?
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 1781)

Adds the error message to the error container.

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

Set the From and FromName properties

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

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 932)

Set the body wrapping.

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

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

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

Closes the active SMTP session if one exists.

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

Initiates a connection to an SMTP server.

Returns false if the operation failed.

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

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 1200)

Returns a formatted mail line.

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

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
ValidateAddress (line 464)

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
WrapText (line 812)

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
_mime_types (line 1915)

Gets the MIME type of the embedded or inline image

  • return: MIME type of ext
  • static:
  • access: public
string _mime_types ([string $ext = ''])
  • string $ext: File extension
Class Constants
STOP_CONTINUE = 1 (line 280)
STOP_CRITICAL = 2 (line 281)
STOP_MESSAGE = 0 (line 279)
VERSION = '5.0.0' (line 278)

Documentation generated on Thu, 02 Apr 2009 17:51:25 -0400 by phpDocumentor 1.3.0RC3