\Hazaar
Mail
Common class for sending emails via different transport mechanisms.

This class provides a common interface for send emails via transport backends. These backends can be anything from local sendmail execution via the PHP mail() command, or directly using SMTP.

Tags

Since

1.0.0

Summary
Methods Properties Constants
$to
No constants
Properties
$body
$body
Static
$default_transport
$default_transport
$from
$from
$headers
$headers
$subject
$subject
$to
$to
$transport
$transport
Methods
__construct()
__construct($transport = null)
The mail class constructor

If a transport is not provided then the Hazaar\Mail\Transport\Local transport will be used.

Parameters

$transport\Hazaar\Mail\Transport

The transport backend to use.

addTo()
addTo($email, $name = null)
Set the 'To:' address header of the email

Parameters

$emailstring

The email address

$namestring

The name part

encodeEmailAddress()
encodeEmailAddress($email, $name)
Encodes an email address into RFC5322 standard format.

Parameters

$emailstring

The email address

$namestring

The name part

getBody()
getBody($params = Array ( ) ) : string
Get the current body part of the email

Parameters

$params

No description

Returns

string

The body of the email

send()
send($params = Array ( ) ) : boolean
Send the email using the current transport backend

Parameters

$params

No description

Returns

boolean

True/false as to whether the transmission was successful

setBodyHTML()
setBodyHTML($html)
Sets a the HTML body of the email

Parameters

$htmlstring

The HTML body of the email

setBodyTemplate()
setBodyTemplate($template)
Set an email template to use as the email body

Parameters

$template\Hazaar\Mail\Template

The template to use.

setBodyText()
setBodyText($body)
Sets the plain text body of the email

Parameters

$bodystring

The plain text body of the email

Static
setDefaultTransport()
setDefaultTransport($transport)
Set the transport backend that should be used

Parameters

$transport\Hazaar\Mail\Transport

The transport backend to use.

setExtraHeaders()
setExtraHeaders($headers)

Parameters

$headers

No description

setFrom()
setFrom($email, $name = null)
Set the 'From:' address header of the email

Parameters

$emailstring

The email address

$namestring

The name part

setReplyTo()
setReplyTo($email, $name = null)
Set the 'Reply-To:' address header of the email

Parameters

$emailstring

The email address

$namestring

The name part

setSubject()
setSubject($subject)
Set the 'Subject' header of the email

Parameters

$subjectstring

The email address