Craft Emails (2.x)

EmailsService extends Component
in package

Table of Contents

CONFIG_KEY  = 'emails'
EVENT_AFTER_DELETE  = 'after-delete'
EVENT_AFTER_SAVE  = 'after-save'
EVENT_BEFORE_APPLY_DELETE  = 'before-apply-delete'
EVENT_BEFORE_DELETE  = 'before-delete'
EVENT_BEFORE_SAVE  = 'before-save'
$_emails  : mixed
delete()  : bool
Delete an email
deleteLogs()  : mixed
Delete logs for an email
getAll()  : array<string|int, mixed>
Get all emails
getAllCustoms()  : array<string|int, mixed>
Get all custom emails
getById()  : Email
Get Email by id
getByKey()  : Email|null
Get email by key
getByUid()  : Email
Get Email by uid
getLogById()  : EmailLog
Get an email log by id
getLogs()  : array<string|int, mixed>
Get logs for an email
getRecordById()  : Email|null
Get record by id
handleChanged()  : mixed
Handle project config change
handleDeleted()  : mixed
Handle project config deletion
install()  : bool
Install system emails.
rebuildConfig()  : mixed
Respond to rebuild config event
resend()  : bool
Resend an email from a log
save()  : bool
Save an email
getRecordByUid()  : Email
Get record by uid
isInProjectConfig()  : bool
Does an email key exist in project config files
triggerEvent()  : mixed
Trigger an event

Constants

EVENT_AFTER_DELETE

public mixed EVENT_AFTER_DELETE = 'after-delete'

EVENT_AFTER_SAVE

public mixed EVENT_AFTER_SAVE = 'after-save'

EVENT_BEFORE_APPLY_DELETE

public mixed EVENT_BEFORE_APPLY_DELETE = 'before-apply-delete'

EVENT_BEFORE_DELETE

public mixed EVENT_BEFORE_DELETE = 'before-delete'

EVENT_BEFORE_SAVE

public mixed EVENT_BEFORE_SAVE = 'before-save'

Properties

Methods

delete()

Delete an email

public delete(Email $email[, bool $force = false ]) : bool
Parameters
$email : Email
$force : bool = false
Return values
bool

deleteLogs()

Delete logs for an email

public deleteLogs(Email $email[, array<string|int, mixed>|null $ids = null ]) : mixed
Parameters
$email : Email
$ids : array<string|int, mixed>|null = null
Return values
mixed

getAll()

Get all emails

public getAll() : array<string|int, mixed>
Return values
array<string|int, mixed>

getAllCustoms()

Get all custom emails

public getAllCustoms() : array<string|int, mixed>
Tags
since
2.0.8
Return values
array<string|int, mixed>

getByKey()

Get email by key

public getByKey(string|null $key) : Email|null
Parameters
$key : string|null
Return values
Email|null

getByUid()

Get Email by uid

public getByUid(string $uid) : Email
Parameters
$uid : string
Return values
Email

getLogs()

Get logs for an email

public getLogs(Email $email[, string $order = 'dateCreated' ][, string $orderSide = 'desc' ]) : array<string|int, mixed>
Parameters
$email : Email
$order : string = 'dateCreated'
$orderSide : string = 'desc'
Return values
array<string|int, mixed>

getRecordById()

Get record by id

public getRecordById(string $id) : Email|null
Parameters
$id : string
Return values
Email|null

handleChanged()

Handle project config change

public handleChanged(ConfigEvent $event) : mixed
Parameters
$event : ConfigEvent
Return values
mixed

handleDeleted()

Handle project config deletion

public handleDeleted(ConfigEvent $event) : mixed
Parameters
$event : ConfigEvent
Return values
mixed

install()

Install system emails.

public install() : bool

Add missing emails and delete orphans if they don't exist both in project config and db

Return values
bool

rebuildConfig()

Respond to rebuild config event

public rebuildConfig(RebuildConfigEvent $e) : mixed
Parameters
$e : RebuildConfigEvent
Return values
mixed

save()

Save an email

public save(Email $email[, bool $validate = true ]) : bool
Parameters
$email : Email
$validate : bool = true
Return values
bool

getRecordByUid()

Get record by uid

protected getRecordByUid(string $uid) : Email
Parameters
$uid : string
Return values
Email

isInProjectConfig()

Does an email key exist in project config files

protected isInProjectConfig(string $key) : bool
Parameters
$key : string
Tags
since
2.0.8
Return values
bool

triggerEvent()

Trigger an event

protected triggerEvent(string $type, Event $event) : mixed
Parameters
$type : string
$event : Event
Return values
mixed

Search results