PHP Class SlightPHP\PHPMailer

Mostrar archivo Open project: hetao29/slightphp

Public Properties

Property Type Description
$AltBody string 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.
$Body string If HTML then run IsHTML(true).
$CharSet string Sets the CharSet of the message.
$ConfirmReadingTo string Sets the email address that a reading confirmation will be sent.
$ContentType string Sets the Content-type of the message.
$Encoding string Sets the Encoding of the message. Options for this are "8bit", "7bit", "binary", "base64", and "quoted-printable".
$ErrorInfo string Holds the most recent mailer error message.
$From string Sets the From email address for the message.
$FromName string Sets the From name of the message.
$Helo string Sets the SMTP HELO of the message (Default is $Hostname).
$Host string Hosts will be tried in order.
$Hostname string 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'.
$Mailer string Method to send mail: ("mail", "sendmail", or "smtp").
$MessageID string If empty, a unique id will be generated.
$Password string Sets SMTP password.
$PluginDir string Path to PHPMailer plugins. This is now only useful if the SMTP class is in a different directory than the PHP include path.
$Port integer Sets the default SMTP server port.
$Priority integer Email priority (1 = High, 3 = Normal, 5 = low).
$SMTPAuth boolean Sets SMTP authentication. Utilizes the Username and Password variables.
$SMTPDebug boolean Sets SMTP class debugging on or off.
$SMTPKeepAlive boolean 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().
$SMTPSecure string Options are "", "ssl" or "tls"
$Sender string 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.
$Sendmail string Sets the path of the sendmail program.
$SingleTo boolean Provides the ability to have the TO field process individual emails, instead of sending to entire TO addresses
$Subject string Sets the Subject of the message.
$Timeout integer Sets the SMTP server timeout in seconds. This function will not work with the win32 version.
$Username string Sets SMTP username.
$Version string Holds PHPMailer version.
$WordWrap integer Sets word wrapping on the body of the message to a given number of characters.

Public Methods

Method Description
AddAddress ( string $address, string $name = '' ) : void Adds a "To" address.
AddAttachment ( string $path, string $name = '', string $encoding = 'base64', string $type = 'application/octet-stream' ) : boolean Adds an attachment from a path on the filesystem.
AddBCC ( string $address, string $name = '' ) : void Adds a "Bcc" address. Note: this function works with the SMTP mailer on win32, not with the "mail" mailer.
AddCC ( string $address, string $name = '' ) : void Adds a "Cc" address. Note: this function works with the SMTP mailer on win32, not with the "mail" mailer.
AddCustomHeader ( $custom_header ) : void Adds a custom header.
AddEmbeddedImage ( string $path, string $cid, string $name = '', string $encoding = 'base64', string $type = 'application/octet-stream' ) : boolean 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".
AddReplyTo ( string $address, string $name = '' ) : void Adds a "Reply-to" address.
AddStringAttachment ( string $string, string $filename, string $encoding = 'base64', string $type = 'application/octet-stream' ) : void Adds a string or binary attachment (non-filesystem) to the list.
AddrAppend ( $type, $addr ) : string Creates recipient headers.
AddrFormat ( $addr ) : string Formats an address correctly.
AttachAll ( ) : string Attaches all fs, string, and binary attachments to the message.
Base64EncodeWrapMB ( string $str ) : string Correctly encodes and wraps long multibyte strings for mail headers without breaking lines within a character.
ClearAddresses ( ) : void Clears all recipients assigned in the TO array. Returns void.
ClearAllRecipients ( ) : void Clears all recipients assigned in the TO, CC and BCC array. Returns void.
ClearAttachments ( ) : void Clears all previously set filesystem, string, and binary attachments. Returns void.
ClearBCCs ( ) : void Clears all recipients assigned in the BCC array. Returns void.
ClearCCs ( ) : void Clears all recipients assigned in the CC array. Returns void.
ClearCustomHeaders ( ) : void Clears all custom headers. Returns void.
ClearReplyTos ( ) : void Clears all recipients assigned in the ReplyTo array. Returns void.
CreateBody ( ) : string Assembles the message body. Returns an empty string on failure.
CreateHeader ( ) : string Assembles message header.
EncodeFile ( $path, $encoding = 'base64' ) : string Encodes attachment in requested format. Returns an empty string on failure.
EncodeHeader ( $str, $position = 'text' ) : string Encode a header string to best of Q, B, quoted or none.
EncodeQ ( $str, $position = 'text' ) : string Encode string to q encoding.
EncodeQP ( $input = '', integer $line_max = 76, $space_conv = false ) : string Encode string to quoted-printable.
EncodeString ( $str, $encoding = 'base64' ) : string Encodes string to requested format. Returns an empty string on failure.
EndBoundary ( $boundary ) Returns the end of a message boundary.
GetBoundary ( $boundary, $charSet, $contentType, $encoding ) Returns the start of a message boundary.
GetMailMIME ( ) : string Returns the message MIME.
HasMultiBytes ( string $str ) : boolean Checks if a string contains multibyte characters.
HeaderLine ( $name, $value ) * Returns a formatted header line.
InlineImageExists ( ) : boolean Returns true if an inline attachment is present.
IsError ( ) : boolean Returns true if an error occurred.
IsHTML ( boolean $bool ) : void Sets message type to HTML.
IsMail ( ) : void Sets Mailer to send message using PHP mail() function.
IsQmail ( ) : void Sets Mailer to send message using the qmail MTA.
IsSMTP ( ) : void Sets Mailer to send message using SMTP.
IsSendmail ( ) : void Sets Mailer to send message using the $Sendmail program.
MailSend ( $header, $body ) : boolean Sends mail using the PHP mail() function.
MsgHTML ( $message, $basedir = '' ) Evaluates the message and returns modifications for inline images and backgrounds
SecureHeader ( string $str ) : string Strips newlines to prevent header injection.
Send ( ) : boolean 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.
SendmailSend ( $header, $body ) : boolean Sends mail using the $Sendmail program.
SetLanguage ( string $lang_type = 'en', string $lang_path = 'language/' ) : boolean Sets the language for all class error messages. Returns false if it cannot load the language file. The default language type is English.
SetMessageType ( ) : void Sets the message type.
SetWordWrap ( ) : void Set the body wrapping.
Sign ( $cert_filename, string $key_filename, string $key_pass ) Set the private key file and password to sign the message.
SmtpClose ( ) : void Closes the active SMTP session if one exists.
SmtpConnect ( ) : boolean Initiates a connection to an SMTP server. Returns false if the operation failed.
SmtpSend ( $header, $body ) : boolean Sends mail via SMTP using PhpSMTP (Author: Chris Ryan). Returns bool. Returns false if there is a bad MAIL FROM, RCPT, or DATA input.
TextLine ( $value ) : string Returns a formatted mail line.
UTF8CharBoundary ( string $encodedText, integer $maxLength ) : integer Finds last character boundary prior to maxLength in a utf-8 quoted (printable) encoded string.
WrapText ( $message, $length, $qp_mode = false ) : string Wraps message for use with mailers that do not automatically perform wrapping and for quoted-printable.
_mime_types ( $ext = '' ) : mime Gets the mime type of the embedded or inline image
getFile ( string $filename ) Read a file from a supplied filename and return it.
get_magic_quotes ( )
set ( string $name, mixed $value = '' ) Set (or reset) Class Objects (variables)

Private Methods

Method Description
FixEOL ( $str ) : string Changes every end of line from CR or LF to CRLF.
Lang ( $key ) : string Returns a message in the appropriate language.
RFCDate ( ) : string Returns the proper RFC 822 formatted date.
ServerHostname ( ) : string Returns the server hostname or 'localhost.localdomain' if unknown.
SetError ( $msg ) : void Adds the error message to the error container.

Method Details

AddAddress() public method

Adds a "To" address.
public AddAddress ( string $address, string $name = '' ) : void
$address string
$name string
return void

AddAttachment() public method

Returns false if the file could not be found or accessed.
public AddAttachment ( string $path, string $name = '', string $encoding = 'base64', string $type = 'application/octet-stream' ) : boolean
$path string Path to the attachment.
$name string Overrides the attachment name.
$encoding string File encoding (see $Encoding).
$type string File extension (MIME) type.
return boolean

AddBCC() public method

Adds a "Bcc" address. Note: this function works with the SMTP mailer on win32, not with the "mail" mailer.
public AddBCC ( string $address, string $name = '' ) : void
$address string
$name string
return void

AddCC() public method

Adds a "Cc" address. Note: this function works with the SMTP mailer on win32, not with the "mail" mailer.
public AddCC ( string $address, string $name = '' ) : void
$address string
$name string
return void

AddCustomHeader() public method

Adds a custom header.
public AddCustomHeader ( $custom_header ) : void
return void

AddEmbeddedImage() public method

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".
public AddEmbeddedImage ( string $path, string $cid, string $name = '', string $encoding = 'base64', string $type = 'application/octet-stream' ) : boolean
$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.
return boolean

AddReplyTo() public method

Adds a "Reply-to" address.
public AddReplyTo ( string $address, string $name = '' ) : void
$address string
$name string
return void

AddStringAttachment() public method

This method can be used to attach ascii or binary data, such as a BLOB record from a database.
public AddStringAttachment ( string $string, string $filename, string $encoding = 'base64', string $type = 'application/octet-stream' ) : void
$string string String attachment data.
$filename string Name of the attachment.
$encoding string File encoding (see $Encoding).
$type string File extension (MIME) type.
return void

AddrAppend() public method

Creates recipient headers.
public AddrAppend ( $type, $addr ) : string
return string

AddrFormat() public method

Formats an address correctly.
public AddrFormat ( $addr ) : string
return string

AttachAll() public method

Returns an empty string on failure.
public AttachAll ( ) : string
return string

Base64EncodeWrapMB() public method

Adapted from a function by paravoid at http://uk.php.net/manual/en/function.mb-encode-mimeheader.php
public Base64EncodeWrapMB ( string $str ) : string
$str string multi-byte text to wrap encode
return string

ClearAddresses() public method

Clears all recipients assigned in the TO array. Returns void.
public ClearAddresses ( ) : void
return void

ClearAllRecipients() public method

Clears all recipients assigned in the TO, CC and BCC array. Returns void.
public ClearAllRecipients ( ) : void
return void

ClearAttachments() public method

Clears all previously set filesystem, string, and binary attachments. Returns void.
public ClearAttachments ( ) : void
return void

ClearBCCs() public method

Clears all recipients assigned in the BCC array. Returns void.
public ClearBCCs ( ) : void
return void

ClearCCs() public method

Clears all recipients assigned in the CC array. Returns void.
public ClearCCs ( ) : void
return void

ClearCustomHeaders() public method

Clears all custom headers. Returns void.
public ClearCustomHeaders ( ) : void
return void

ClearReplyTos() public method

Clears all recipients assigned in the ReplyTo array. Returns void.
public ClearReplyTos ( ) : void
return void

CreateBody() public method

Assembles the message body. Returns an empty string on failure.
public CreateBody ( ) : string
return string

CreateHeader() public method

Assembles message header.
public CreateHeader ( ) : string
return string

EncodeFile() public method

Encodes attachment in requested format. Returns an empty string on failure.
public EncodeFile ( $path, $encoding = 'base64' ) : string
return string

EncodeHeader() public method

Encode a header string to best of Q, B, quoted or none.
public EncodeHeader ( $str, $position = 'text' ) : string
return string

EncodeQ() public method

Encode string to q encoding.
public EncodeQ ( $str, $position = 'text' ) : string
return string

EncodeQP() public method

Encode string to quoted-printable.
public EncodeQP ( $input = '', integer $line_max = 76, $space_conv = false ) : string
$line_max integer Number of chars allowed on a line before wrapping
return string

EncodeString() public method

Encodes string to requested format. Returns an empty string on failure.
public EncodeString ( $str, $encoding = 'base64' ) : string
return string

EndBoundary() public method

Returns the end of a message boundary.
public EndBoundary ( $boundary )

GetBoundary() public method

Returns the start of a message boundary.
public GetBoundary ( $boundary, $charSet, $contentType, $encoding )

GetMailMIME() public method

Returns the message MIME.
public GetMailMIME ( ) : string
return string

HasMultiBytes() public method

Checks if a string contains multibyte characters.
public HasMultiBytes ( string $str ) : boolean
$str string multi-byte text to wrap encode
return boolean

HeaderLine() public method

* Returns a formatted header line.
public HeaderLine ( $name, $value )

InlineImageExists() public method

Returns true if an inline attachment is present.
public InlineImageExists ( ) : boolean
return boolean

IsError() public method

Returns true if an error occurred.
public IsError ( ) : boolean
return boolean

IsHTML() public method

Sets message type to HTML.
public IsHTML ( boolean $bool ) : void
$bool boolean
return void

IsMail() public method

Sets Mailer to send message using PHP mail() function.
public IsMail ( ) : void
return void

IsQmail() public method

Sets Mailer to send message using the qmail MTA.
public IsQmail ( ) : void
return void

IsSMTP() public method

Sets Mailer to send message using SMTP.
public IsSMTP ( ) : void
return void

IsSendmail() public method

Sets Mailer to send message using the $Sendmail program.
public IsSendmail ( ) : void
return void

MailSend() public method

Sends mail using the PHP mail() function.
public MailSend ( $header, $body ) : boolean
return boolean

MsgHTML() public method

Evaluates the message and returns modifications for inline images and backgrounds
public MsgHTML ( $message, $basedir = '' )

SecureHeader() public method

Strips newlines to prevent header injection.
public SecureHeader ( string $str ) : string
$str string String
return string

Send() public method

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.
public Send ( ) : boolean
return boolean

SendmailSend() public method

Sends mail using the $Sendmail program.
public SendmailSend ( $header, $body ) : boolean
return boolean

SetLanguage() public method

Sets the language for all class error messages. Returns false if it cannot load the language file. The default language type is English.
public SetLanguage ( string $lang_type = 'en', string $lang_path = 'language/' ) : boolean
$lang_type string Type of language (e.g. Portuguese: "br")
$lang_path string Path to the language file directory
return boolean

SetMessageType() public method

Sets the message type.
public SetMessageType ( ) : void
return void

SetWordWrap() public method

Set the body wrapping.
public SetWordWrap ( ) : void
return void

Sign() public method

Set the private key file and password to sign the message.
public Sign ( $cert_filename, string $key_filename, string $key_pass )
$key_filename string Parameter File Name
$key_pass string Password for private key

SmtpClose() public method

Closes the active SMTP session if one exists.
public SmtpClose ( ) : void
return void

SmtpConnect() public method

Initiates a connection to an SMTP server. Returns false if the operation failed.
public SmtpConnect ( ) : boolean
return boolean

SmtpSend() public method

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

TextLine() public method

Returns a formatted mail line.
public TextLine ( $value ) : string
return string

UTF8CharBoundary() public method

Original written by Colin Brown.
public UTF8CharBoundary ( string $encodedText, integer $maxLength ) : integer
$encodedText string utf-8 QP text
$maxLength integer find last character boundary prior to this length
return integer

WrapText() public method

Original written by philippe.
public WrapText ( $message, $length, $qp_mode = false ) : string
return string

_mime_types() public method

Gets the mime type of the embedded or inline image
public _mime_types ( $ext = '' ) : mime
return mime type of ext

getFile() public method

Read a file from a supplied filename and return it.
public getFile ( string $filename )
$filename string Parameter File Name

get_magic_quotes() public method

public get_magic_quotes ( )

set() public method

Usage Example: $page->set('X-Priority', '3');
public set ( string $name, mixed $value = '' )
$name string Parameter Name
$value mixed Parameter Value NOTE: will not work with arrays, there are no arrays to set/reset

Property Details

$AltBody public_oe property

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.
public string $AltBody
return string

$Body public_oe property

If HTML then run IsHTML(true).
public string $Body
return string

$CharSet public_oe property

Sets the CharSet of the message.
public string $CharSet
return string

$ConfirmReadingTo public_oe property

Sets the email address that a reading confirmation will be sent.
public string $ConfirmReadingTo
return string

$ContentType public_oe property

Sets the Content-type of the message.
public string $ContentType
return string

$Encoding public_oe property

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

$ErrorInfo public_oe property

Holds the most recent mailer error message.
public string $ErrorInfo
return string

$From public_oe property

Sets the From email address for the message.
public string $From
return string

$FromName public_oe property

Sets the From name of the message.
public string $FromName
return string

$Helo public_oe property

Sets the SMTP HELO of the message (Default is $Hostname).
public string $Helo
return string

$Host public_oe property

Hosts will be tried in order.
public string $Host
return string

$Hostname public_oe property

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'.
public string $Hostname
return string

$Mailer public_oe property

Method to send mail: ("mail", "sendmail", or "smtp").
public string $Mailer
return string

$MessageID public_oe property

If empty, a unique id will be generated.
public string $MessageID
return string

$Password public_oe property

Sets SMTP password.
public string $Password
return string

$PluginDir public_oe property

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

$Port public_oe property

Sets the default SMTP server port.
public int $Port
return integer

$Priority public_oe property

Email priority (1 = High, 3 = Normal, 5 = low).
public int $Priority
return integer

$SMTPAuth public_oe property

Sets SMTP authentication. Utilizes the Username and Password variables.
public bool $SMTPAuth
return boolean

$SMTPDebug public_oe property

Sets SMTP class debugging on or off.
public bool $SMTPDebug
return boolean

$SMTPKeepAlive public_oe property

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().
public bool $SMTPKeepAlive
return boolean

$SMTPSecure public_oe property

Options are "", "ssl" or "tls"
public string $SMTPSecure
return string

$Sender public_oe property

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.
public string $Sender
return string

$Sendmail public_oe property

Sets the path of the sendmail program.
public string $Sendmail
return string

$SingleTo public_oe property

Provides the ability to have the TO field process individual emails, instead of sending to entire TO addresses
public bool $SingleTo
return boolean

$Subject public_oe property

Sets the Subject of the message.
public string $Subject
return string

$Timeout public_oe property

Sets the SMTP server timeout in seconds. This function will not work with the win32 version.
public int $Timeout
return integer

$Username public_oe property

Sets SMTP username.
public string $Username
return string

$Version public_oe property

Holds PHPMailer version.
public string $Version
return string

$WordWrap public_oe property

Sets word wrapping on the body of the message to a given number of characters.
public int $WordWrap
return integer