PHPMailer - PHP email transport class

package PHPMailer
author Brent R. Matzelle
copyright 2001 - 2003 Brent R. Matzelle
deprecated 2012-26-09 Use cMailer instead!

 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.

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

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

Parameters

$address

string

$name

string

Adds a "Cc" address.

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

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

Parameters

$address

string

$name

string

Adds a custom header.

AddCustomHeader($custom_header) : void

Parameters

$custom_header

Adds an embedded attachment.

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

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

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.

ClearAddresses() : void

Returns void.

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

ClearAllRecipients() : void

Returns void.

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

ClearAttachments() : void

Returns void.

Clears all recipients assigned in the BCC array.

ClearBCCs() : void

Returns void.

Clears all recipients assigned in the CC array.

ClearCCs() : void

Returns void.

Clears all custom headers.

ClearCustomHeaders() : void

Returns void.

Clears all recipients assigned in the ReplyTo array.

ClearReplyTos() : void

Returns void.

Assembles the message body.

CreateBody() : string

Returns an empty string on failure.

access private

Returns

string

Assembles message header.

CreateHeader() : string
access private

Returns

string

Encodes attachment in requested format.

EncodeFile($path, $encoding) : string

Returns an empty string on failure.

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.

EncodeString($str, $encoding) : string

Returns an empty string on failure.

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.

Send() : bool

If the message is not sent successfully then it returns false. Use the ErrorInfo variable to view description of the error.

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.

ServerVar($varName) : mixed

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

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.

SmtpConnect() : bool

Returns false if the operation failed.

access private

Returns

bool

Sends mail via SMTP using PhpSMTP (Author: Chris Ryan).

SmtpSend($header, $body) : bool

Returns bool. Returns false if there is a bad MAIL FROM, RCPT, or DATA input.

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

 

$AltBody : string

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.

 

$Body : string

This can be either an HTML or text body. If HTML then run IsHTML(true).

 

$CharSet : string
 

$ConfirmReadingTo : string
 

$ContentType : string
 

$CustomHeader 
 

$Encoding : string

Options for this are "8bit", "7bit", "binary", "base64", and "quoted-printable".

 

$ErrorInfo : string
 

$From : string
 

$FromName : string
 

$Helo 

@var string

 

$Host : string

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.

 

$Hostname : string

If empty, the value returned by SERVER_NAME is used or 'localhost.localdomain'.

 

$LE 
 

$Mailer : string
 

$Password 

@var string

 

$PluginDir : string

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

 

$Port 

@var int

 

$Priority : int
 

$ReplyTo 
 

$SMTPAuth : bool

Utilizes the Username and Password variables.

 

$SMTPDebug 

@var bool

 

$SMTPKeepAlive : bool

If this is set to true then to close the connection requires an explicit call to SmtpClose().

 

$Sender : string

If not empty, will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.

 

$Sendmail : string
 

$Subject : string
 

$Timeout : int

This function will not work with the win32 version.

 

$Username 

@var string

 

$Version 

@var string

 

$WordWrap : int
 

$attachment 
 

$bcc 
 

$boundary 
 

$cc 
 

$error_count 
 

$message_type 
 

$smtp 
 

$to