PHPMailer - PHP email transport class

package PHPMailer
author Brent R. Matzelle
copyright 2001 - 2003 Brent R. Matzelle

 Methods

Adds a "To" address.

AddAddress(string $address, string $name) : void

Parameters

$address

string

$name

string

Adds an attachment from a path on the filesystem.

AddAttachment(string $path, string $name, string $encoding, string $type) : bool

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

Parameters

$path

string

Path to the attachment.

$name

string

Overrides the attachment name.

$encoding

string

File encoding (see $Encoding).

$type

string

File extension (MIME) type.

Returns

bool

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

AddBCC(string $address, string $name) : void

Parameters

$address

string

$name

string

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

AddCC(string $address, string $name) : void

Parameters

$address

string

$name

string

Adds a custom header.

AddCustomHeader($custom_header) : void

Parameters

$custom_header

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

AddEmbeddedImage(string $path, string $cid, string $name, string $encoding, string $type) : bool

Parameters

$path

string

Path to the attachment.

$cid

string

Content ID of the attachment. Use this to identify the Id for accessing the image in an HTML form.

$name

string

Overrides the attachment name.

$encoding

string

File encoding (see $Encoding).

$type

string

File extension (MIME) type.

Returns

bool

Adds a "Reply-to" address.

AddReplyTo(string $address, string $name) : void

Parameters

$address

string

$name

string

Adds a string or binary attachment (non-filesystem) to the list.

AddStringAttachment(string $string, string $filename, string $encoding, string $type) : void

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

Parameters

$string

string

String attachment data.

$filename

string

Name of the attachment.

$encoding

string

File encoding (see $Encoding).

$type

string

File extension (MIME) type.

Creates recipient headers.

AddrAppend($type, $addr) : string

access private

Parameters

$type

$addr

Returns

string

Formats an address correctly.

AddrFormat($addr) : string

access private

Parameters

$addr

Returns

string

Attaches all fs, string, and binary attachments to the message.

AttachAll() : string

Returns an empty string on failure.

access private

Returns

string

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

ClearAddresses() : void

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

ClearAllRecipients() : void

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

ClearAttachments() : void

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

ClearBCCs() : void

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

ClearCCs() : void

Clears all custom headers. Returns void.

ClearCustomHeaders() : void

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

ClearReplyTos() : void

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

CreateBody() : string

access private

Returns

string

Assembles message header.

CreateHeader() : string

access private

Returns

string

Encodes attachment in requested format. Returns an empty string on failure.

EncodeFile($path, $encoding) : string

access private

Parameters

$path

$encoding

Returns

string

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

EncodeHeader($str, $position) : string

access private

Parameters

$str

$position

Returns

string

Encode string to q encoding.

EncodeQ($str, $position) : string

access private

Parameters

$str

$position

Returns

string

Encode string to quoted-printable.

EncodeQP($str) : string

access private

Parameters

$str

Returns

string

Encodes string to requested format. Returns an empty string on failure.

EncodeString($str, $encoding) : string

access private

Parameters

$str

$encoding

Returns

string

Returns the end of a message boundary.

EndBoundary($boundary) 

access private

Parameters

$boundary

Changes every end of line from CR or LF to CRLF.

FixEOL($str) : string

access private

Parameters

$str

Returns

string

Returns the start of a message boundary.

GetBoundary($boundary, $charSet, $contentType, $encoding) 

access private

Parameters

$boundary

$charSet

$contentType

$encoding

Returns a formatted header line.

HeaderLine($name, $value) : string

access private

Parameters

$name

$value

Returns

string

Returns true if an inline attachment is present.

InlineImageExists() : bool

access private

Returns

bool

Returns true if an error occurred.

IsError() : bool

Returns

bool

Sets message type to HTML.

IsHTML(bool $bool) : void

Parameters

$bool

bool

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

IsMail() : void

Sets Mailer to send message using the qmail MTA.

IsQmail() : void

Sets Mailer to send message using SMTP.

IsSMTP() : void

Sets Mailer to send message using the $Sendmail program.

IsSendmail() : void

Sends mail using the PHP mail() function.

MailSend($header, $body) : bool

access private

Parameters

$header

$body

Returns

bool

Returns the proper RFC 822 formatted date.

RFCDate() : string

access private

Returns

string

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.

Send() : bool

Returns

bool

Sends mail using the $Sendmail program.

SendmailSend($header, $body) : bool

access private

Parameters

$header

$body

Returns

bool

Returns the server hostname or 'localhost.localdomain' if unknown.

ServerHostname() : string

access private

Returns

string

Returns the appropriate server variable. Should work with both PHP 4.1.0+ as well as older versions. Returns an empty string if nothing is found.

ServerVar($varName) : mixed

access private

Parameters

$varName

Returns

mixed

Adds the error message to the error container.

SetError($msg) : void

Returns void.

access private

Parameters

$msg

Sets the message type.

SetMessageType() : void

access private

Set the body wrapping.

SetWordWrap() : void

access private

Closes the active SMTP session if one exists.

SmtpClose() : void

Initiates a connection to an SMTP server. Returns false if the operation failed.

SmtpConnect() : bool

access private

Returns

bool

Sends mail via SMTP using PhpSMTP (Author: Chris Ryan). Returns bool. Returns false if there is a bad MAIL FROM, RCPT, or DATA input.

SmtpSend($header, $body) : bool

access private

Parameters

$header

$body

Returns

bool

Returns a formatted mail line.

TextLine($value) : string

access private

Parameters

$value

Returns

string

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

WrapText($message, $length, $qp_mode) : string

Original written by philippe.

access private

Parameters

$message

$length

$qp_mode

Returns

string

 Properties

 

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.

$AltBody : string

 

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

$Body : string

If HTML then run IsHTML(true).

 

Sets the CharSet of the message.

$CharSet : string

 

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

$ConfirmReadingTo : string

 

Sets the Content-type of the message.

$ContentType : string

 

$CustomHeader

$CustomHeader 

 

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

$Encoding : string

 

Holds the most recent mailer error message.

$ErrorInfo : string

 

Sets the From email address for the message.

$From : string

 

Sets the From name of the message.

$FromName : string

 

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

$Helo 

@var string

 

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

$Host : string

Hosts will be tried in order.

 

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

$Hostname 

@var string

 

$LE

$LE 

 

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

$Mailer : string

 

Sets SMTP password.

$Password 

@var string

 

Path to PHPMailer plugins. This is now only useful if the SMTP class is in a different directory than the PHP include path.

$PluginDir : string

 

Sets the default SMTP server port.

$Port 

@var int

 

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

$Priority : int

 

$ReplyTo

$ReplyTo 

 

Sets SMTP authentication. Utilizes the Username and Password variables.

$SMTPAuth 

@var bool

 

Sets SMTP class debugging on or off.

$SMTPDebug 

@var bool

 

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

$SMTPKeepAlive : bool

 

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.

$Sender : string

 

Sets the path of the sendmail program.

$Sendmail : string

 

Sets the Subject of the message.

$Subject : string

 

Sets the SMTP server timeout in seconds. This function will not work with the win32 version.

$Timeout 

@var int

 

Sets SMTP username.

$Username 

@var string

 

Holds PHPMailer version.

$Version 

@var string

 

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

$WordWrap : int

 

$attachment

$attachment 

 

$bcc

$bcc 

 

$boundary

$boundary 

 

$cc

$cc 

 

$error_count

$error_count 

 

$message_type

$message_type 

 

$smtp

$smtp 

 

$to

$to