Adapter
Adapter
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.
Configuration Settings
- enable - BOOLEAN - This is TRUE by default. Setting to FALSE will cause any calls to
Adapter::send()
to throw an\Exception
. - transport - STRING - This is the default transport to use when one is not specified. Currently supports 'local' and 'smtp'.
- testmode - BOOLEAN - This is FALSE by default. Setting it to TRUE will activate test mode. This is exactly the same as disabling emails with
enable = FALSE
except that it will simulate a successful transmission. - override - This allows recipient emails to be overriden with the email address listed.
- to - ARRAY - Override all 'to' recipient addresses with the list provided.
- cc - ARRAY - Override all 'cc' recipient addresses with the list provided.
- bcc - ARRAY - Override all 'bcc' recipient addresses with the list provided.
- noOverrideMatch - REGEX - Do not override any 'to' recipient email address that match this regex.
Override email address can be either plain strings, or an Array where index 0 is the email address, and index 1 is the recipient name.
Example #1: [ "[email protected]" ]
Example #2: [ [ "[email protected]", "Hazaar Labs Support" ] ]
Properties
default_transport
protected string $default_transport
transport
protected Transport $transport
message
protected TransportMessage $message
subject
public Template $subject
body
protected mixed $body
last_to
protected array $last_to
config
protected Map $config
Methods
__construct
The mail class constructor.
public __construct({Array})
If a transport is not provided then the [[Hazaar\Mail\Transport\Local]] transport will be used.
Parameters
Parameter | Type | Description |
---|---|---|
$config | Map | the configuration settings for the mail adapter |
getTransportObject
public getTransportObject({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$transport | string | |
$config | Map |
setDefaultTransport
public setDefaultTransport({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$transport | string |
setFrom
Set the 'From:' address header of the email.
public setFrom({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$email | string | The email address |
$name | string | The name part |
setReplyTo
Set the 'Reply-To:' address header of the email.
public setReplyTo({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$email | string | The email address |
$name | string | The name part |
setReturnPath
Sets the return path for the email.
public setReturnPath({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$email | string | the email address to set as the return path |
$name | string | the name associated with the email address (optional) |
clear
Clear all recipients ready for re-using the adapter.
public clear({Array})
This is for working with templates that need to be sent/rendered multiple times to send to many recipients.
Parameters
Parameter | Type | Description |
---|---|---|
$clear_attachments | bool |
addTo
Set the 'To:' address header of the email.
public addTo({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$email | string | The email address |
$name | string | The name part |
getTo
Get the 'To:' address header of the email.
public getTo({Array})
getLastTo
Get the last 'To:' address header of the email.
public getLastTo({Array})
addCC
Set the 'CC:' address header of the email.
public addCC({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$email | string | |
$name | string |
getCC
Get the 'CC:' address header of the email.
public getCC({Array})
addBCC
Set the 'BCC:' address header of the email.
public addBCC({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$email | string | |
$name | string |
getBCC
Get the 'BCC:' address header of the email.
public getBCC({Array})
setSubject
Set the 'Subject' header of the email.
public setSubject({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$subject | Template |
setBodyText
Sets the plain text body of the email.
public setBodyText({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$body | string | The plain text body of the email |
setBodyHTML
Sets a the HTML body of the email.
public setBodyHTML({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$html | mixed |
addAttachment
public addAttachment({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$file | File | |
$name | string |
setBodyTemplate
Set an email template to use as the email body.
public setBodyTemplate({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$template | Template | the template to use |
loadTemplate
Load load a template to use as the TEXT email body.
public loadTemplate({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$filename | string | The filename to load the template from |
loadHTMLTemplate
Load a template to use as the HTML email body.
public loadHTMLTemplate({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$filename | string | The filename to load the template from |
getBody
Get the current body part of the email.
public getBody({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$params | array |
setExtraHeaders
Set extra headers to be included in the email.
public setExtraHeaders({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$headers | array |
send
Send the email using the current transport backend.
public send({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$params | array |
enableDSN
Enables ALL Delivery Status Notification types.
public enableDSN({Array})
disableDSN
Disable ALL Delivery Status Notifications.
public disableDSN({Array})
enableDSNSuccess
Enables SUCCESS Delivery Status Notification types.
public enableDSNSuccess({Array})
enableDSNFailure
Enables SUCCESS Delivery Status Notification types.
public enableDSNFailure({Array})
enableDSNDelay
Enables SUCCESS Delivery Status Notification types.
public enableDSNDelay({Array})
encodeEmailAddress
protected encodeEmailAddress({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$email | string | |
$name | string |
resetDSN
protected resetDSN({Array})
Generated by Hazaar API Doc Generator