Wraps PEAR's Mail and Mail_mime packages.

Provides a little extra functionality.
Requires PEAR mail and mail_mime (if you want to add attachements) packages installed.
Can send single attachements and plain text or html/plain mails. This functionality is automatic dependant on what content has been added to the mail before send.

package dstruct_common

 Methods

Class constructor.

__construct() 

Attach a file to the email

attach(string $file, string $mime) 

Parameters

$file

string

Path and name of the file

$mime

string

File's mime-type

Reset the object.

clear(string $clearcredentials) 

If $clearcredentials is true then will also reset the credentials to the defaults (will use the ones if set in Prefs) and the replyto field.

Parameters

$clearcredentials

string

Reset credentials to defaults

Email body.

getBody() : string

Returns

string

From field of email.

getFrom() : string

Returns

string

SMTP host setting.

getHost() : string

Returns

string

Whether to use header() or a javascript window.location script to redirect the user on successful send.

getJavascriptRedirect() : boolean
see \setJavascriptRedirect()

Returns

boolean

Set the port of the SMTP MTA.

getPort() : integer

Port would usually be 25, but many ISPs and companies use other ports for authenticated emails. This allows sending from outside the 'trusted hosts' if credentials are provided.

Returns

integer

Location user will be redirected to on successful send.

getRedirect() : string

Returns

string

Email ReplyTo field.

getReplyTo() : string

Returns

string

Subject field of email.

getSubject() : string

Returns

string

To field of email.

getTo() : string

Returns

string

SMTP user name setting.

getUserName() : string

Returns

string

Commits the SMTP send using PEAR mail.

send() : boolean

N.B. Also attempts to redirect user depending on vars $redirectlocation and SMTPEmail::$javascriptredirect.
Automatically selects plain text or mime email depending on what content or attachements have been added.

Returns

boolean

Set email Body.

setBody(string $body) 

Parameters

$body

string

Set the HTML body of the email Will automatically trigger creating a mime email if set.

setBodyHTML(string $html) 

Parameters

$html

string

Set email From field.

setFrom(string $from) 

Parameters

$from

string

Set SMTP host e.g.

setHost(string $host) 

mail0.conceptia.co.uk

Parameters

$host

string

Set javascript redirect.

setJavascriptRedirect(boolean $javascriptredirect) 

True echos a javascript window.location call to the browser. False uses a PHP header() call, which is the default.

Parameters

$javascriptredirect

boolean

Set SMTP password.

setPassword(string $password) 

Parameters

$password

string

Set Host port.

setPort(integer $port) 

Port would usually be 25, but many ISPs and companies use other ports for authenticated emails. This allows sending from outside the 'trusted hosts' if credentials are provided.

Parameters

$port

integer

Set the email recipient.

setRecipient(string $to) 

Parameters

$to

string

Set location to redirect user on successful send.

setRedirect(string $redirectlocation) 

WARNING: Be careful with this setting as it is echoed straight out to the browser and under certain circumstances could be a security hole. This method does no checking on the validity or security of the input so you must do this in your script.

Parameters

$redirectlocation

string

Set email ReplyTo field.

setReplyTo(string $replyto) 

Parameters

$replyto

string

Set email Subject

setSubject(string $subject) 

Parameters

$subject

string

Set Email To field

setTo(string $to) 

Parameters

$to

string

Set SMTP username

setUserName(string $username) 

Parameters

$username

string

Set the credentials from {@link Prefs} constants.

setDefaultCredentials() 

 Properties

 

$attachment : string
 

$attachmentmime : string
 

$body : string
 

$bodyhtml : string
 

$from : string
 

$host : string
 

$javascriptredirect : boolean

If set to false, uses header() to redirect to the redirect location. If set to true, echos a javascript block with a window.location call

 

$port : \inteter
 

$redirectlocation : string
 

$replyto : string
 

$subject : string
 

$to : string
 

$username : string