cms_mailer View code

A class for sending email.

Prior to CMSMS 2.0 this class was implemented as a core module.

package

CMS

license

GPL

since 2.0
author

Robert Campbell (calguy1000@cmsmadesimple.org)

Methods

__construct(boolean $exceptions = true) 

Constructor

Arguments

boolean $exceptions

Optionally disable exceptions, and rely on error strings.

reset() 

Reset the mailer to standard settings

GetAltBody() : string

Retrieve the alternate body of the email message

Response

string

SetAltBody(string $txt) 

Set the alternate body of the email message

For HTML messages the alternate body contains a text only string for email clients without HTML support.

Arguments

string $txt

GetBody() : string

Retrieve the body of the email message

Response

string

SetBody(string $txt) 

Set the body of the email message.

If the email message is in HTML format this can contain HTML code. Otherwise it should contain only text.

Arguments

string $txt

GetCharSet() : string

Return the character set for the email

Response

string

SetCharSet(string $charset) 

Set the character set for the message.

Normally, the reset routine sets this to a system wide default value.

Arguments

string $charset

GetConfirmReadingTo() : string

Retrieve the reading confirmation email address

Response

string

The email address (if any) that will recieve the reading confirmation.

SetConfirmReadingTo(string $email) 

Set the email address that confirmations of email reading will be sent to.

Arguments

string $email

GetEncoding() : string

Get the encoding of the message.

Response

string

SetEncoding(string $encoding) 

Sets the encoding of the message.

Possible values are: 8bit, 7bit, binary, base64, and quoted-printable

Arguments

string $encoding

GetErrorInfo() : string

Return the error information from the last error.

Response

string

GetFrom() : string

Get the from address for the email

Response

string

SetFrom(string $email) 

Set the from address for the email

Arguments

string $email

Th email address that the email will be from.

GetFromName() : string

Get the real name that the email will be sent from

Response

string

SetFromName(string $name) 

Set the real name that this email will be sent from.

Arguments

string $name

GetHelo() : string

Gets the SMTP HELO of the message

Response

string

SetHelo(string $helo) 

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

Arguments

string $helo

GetSMTPHost() : string

Get the SMTP host values

Response

string

SetSMTPHost(string $host) 

Set the SMTP host(s).

Only applicable when using SMTP mailer. All hosts must be separated with a semicolon. you can also specify a different port for each host by using the format hostname:port (e.g. "smtp1.example.com:25;smtp2.example.com"). Hosts will be tried in order

Arguments

string $host

GetHostname() : string

Get the hostname that will be used in the Message-Id and Recieved headers and the default HELO string.

Response

string

SetHostname(string $hostname) 

Set the hostname to use in the Message-Id and Received headers and as the default HELO string. If empty the value will be calculated

Arguments

string $hostname

GetMailer() : string

Retrieve the name of the mailer that will be used to send the message.

Response

string

SetMailer(string $mailer) 

Set the name of the mailer that will be used to send the message.

possible values for this field are 'mail','smtp', and 'sendmail'

Arguments

string $mailer

GetSMTPPassword() : string

Get the SMTP password

Response

string

SetSMTPPassword(string $password) 

Set the SMTP password

Only useful when using the SMTP mailer.

Arguments

string $password

GetSMTPPort() : integer

Get the default SMTP port number

Response

integer

SetSMTPPort(integer $port) 

Set the default SMTP port

This method is only useful when using the SMTP mailer.

Arguments

integer $port

GetPriority() : integer

Get the priority of the message

Response

integer

SetPriority(integer $priority) 

Set the priority of the message (1 = High, 3 = Normal, 5 = low)

Arguments

integer $priority

GetSender() : string

Get the Sender (return-path) of the message.

Response

string

The email address for the Sender field

SetSender(string $sender) 

Set the Sender email (return-path) of the message.

Arguments

string $sender

GetSendmail() 

Get the path to the sendmail executable

SetSendmail(string $path) 

Set the path to the sendmail executable

This path is only useful when using the sendmail mailer.

Arguments

string $path

GetSMTPAuth() : boolean

Retrieve the SMTP Auth flag

Response

boolean

SetSMTPAuth(boolean $flag = true) 

Set a flag indicating wether or not SMTP authentication is to be used when sending mails via the SMTP mailer.

Arguments

boolean $flag

GetSMTPDebug() : boolean

Get the current value of the SMTP Debug flag

Response

boolean

SetSMTPDebug(boolean $flag = TRUE) 

Enable, or disable SMTP debugging

This is only useful when using the SMTP mailer.

Arguments

boolean $flag

GetSMTPKeepAlive() : boolean

Return the value of the SMTP keepalive flag

Response

boolean

SetSMTPKeepAlive(boolean $flag = true) 

Prevents the SMTP connection from being closed after sending each message.

If this is set to true then SmtpClose must be used to close the connection

This method is only useful when using the SMTP mailer.

Arguments

boolean $flag

GetSubject() : string

Retrieve the subject of the message

Response

string

SetSubject(string $subject) 

Set the subject of the message

Arguments

string $subject

GetSMTPTimeout() : integer

Get the SMTP server timeout (in seconds).

Response

integer

SetSMTPTimeout(integer $timeout) 

Set the SMTP server timeout in seconds (for the SMTP mailer) This function may not work with the win32 version.

Arguments

integer $timeout

GetSMTPUsername() : string

Get the SMTP username

Response

string

SetSMTPUsername(string $username) 

Set the SMTP Username.

This is only used when using the SMTP mailer with SMTP authentication.

Arguments

string $username

GetWordWrap() : integer

Get the number of characters used in word wrapping. 0 indicates that no word wrapping will be performed.

Response

integer

SetWordWrap(integer $chars) 

Set word wrapping on the body of the message to the given number of characters

Arguments

integer $chars

AddAddress(string $address, string $name = '') : boolean

Add a "To" address.

Arguments

string $address

The email address

string $name

The real name

Response

boolean

true on success, false if address already used

AddAttachment(string $path, string $name = '', string $encoding = 'base64', string $type = 'application/octet-stream') : boolean

Adds an attachment from a path on the filesystem

Arguments

string $path

Complete file specification to the attachment

string $name

Set the attachment name

string $encoding

File encoding (see $encoding)

string $type

(mime type for the attachment)

Response

boolean

true on success, false on failure.

AddBCC(string $addr, string $name = '') : boolean

Add a "BCC" (Blind Carbon Copy) address

Arguments

string $addr

The email address

string $name

The real name.

Response

boolean

true on success, false on failure.

AddCC(string $addr, string $name = '') : boolean

Add a "CC" (Carbon Copy) address

Arguments

string $addr

The email address

string $name

The real name.

Response

boolean

true on success, false on failure.

AddCustomHeader(string $header) 

Add a custom header to the output email

i.e: $obj->AddCustomHeader('X-MYHEADER: some-value');

Arguments

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

Arguments

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.

Response

boolean

AddReplyTo(string $addr, string $name = '') : boolean

Adds a "Reply-to" address.

Arguments

string $addr

string $name

Response

boolean

AddStringAttachment(string $string, string $filename, string $encoding = 'base64', string $type = 'application/octet-stream') 

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.

Arguments

string $string

String attachment data.

string $filename

Name of the attachment.

string $encoding

File encoding (see $Encoding).

string $type

File extension (MIME) type.

ClearAddresses() 

Clears all recipients in the To list

ClearAllRecipients() 

Clears all recipients in the To,CC, and BCC lists

ClearAttachments() 

Clears all attachments

ClearBCCs() 

Clear all recipients on the BCC list

ClearCCs() 

Clear all recipients on the CC list

ClearCustomHeaders() 

Clear all custom headers

ClearReplyTos() 

Clear the Reply-To list

IsError() : boolean

Test if there was an error on the last message send

Response

boolean

IsHTML(boolean $html = true) 

Set the message type to HTML.

Arguments

boolean $html

IsMail() : boolean

Test if the mailer is set to 'mail'

Response

boolean

IsSendmail() : boolean

Test if the mailer is set to 'sendmail'

Response

boolean

IsSMTP() : boolean

Test if the mailer is set to 'SMTP'

Response

boolean

Send() : boolean

Send the current message using all current settings.

This method may throw exceptions if $exceptions were enabled in the constructor

Response

boolean

SetLanguage(string $lang_type) 

Set the language for all error messages

Arguments

string $lang_type

SmtpClose() 

Close the SMTP connection Only necessary when using the SMTP mailer with keepalive enaboed.

GetSMTPSecure() : string

Gets the secure SMTP connection mode, or none

Response

string

SetSMTPSecure(string $value) 

Set the secure SMTP connection mode, or none possible values are "", "ssl", or "tls"

Arguments

string $value