Documentation

EmailSender
in package

Read onlyYes
FinalYes

Table of Contents

Constants

DEFAULT_CONTENT_TYPE  : string = 'text/html'

Properties

$context  : HostComponentContextInterface|null
$logger  : LoggerInterface

Methods

__construct()  : mixed
send()  : bool
Send an email using a template.
sendBulk()  : array<string|int, mixed>
Send email to multiple recipients.
sendRaw()  : bool
Send a simple email without template (plain text or raw HTML).
withFrom()  : self
Set the "From" name and email for the next send via WP filters.
getTemplateCandidatePaths()  : array<int, array{0: string, 1: null|string}>
Returns ordered list of [htmlPath, plainPath|null] pairs to check.
resolveTemplate()  : EmailTemplate|null

Constants

DEFAULT_CONTENT_TYPE

private string DEFAULT_CONTENT_TYPE = 'text/html'

Properties

$context

private HostComponentContextInterface|null $context = null

$logger

private LoggerInterface $logger = new ErrorLogFallbackLogger()

Methods

__construct()

public __construct([LoggerInterface $logger = new ErrorLogFallbackLogger() ][, HostComponentContextInterface|null $context = null ]) : mixed
Parameters
$logger : LoggerInterface = new ErrorLogFallbackLogger()
$context : HostComponentContextInterface|null = null

send()

Send an email using a template.

public send(string $to, string $subject, string $templateName[, array<string|int, mixed> $data = [] ][, array<string|int, mixed> $headers = [] ][, array<string|int, mixed> $attachments = [] ]) : bool
Parameters
$to : string
$subject : string
$templateName : string
$data : array<string|int, mixed> = []
$headers : array<string|int, mixed> = []
$attachments : array<string|int, mixed> = []
Return values
bool

sendBulk()

Send email to multiple recipients.

public sendBulk(array<string|int, mixed> $recipients, string $subject, string $templateName[, array<string|int, mixed> $data = [] ][, array<string|int, mixed> $headers = [] ]) : array<string|int, mixed>
Parameters
$recipients : array<string|int, mixed>
$subject : string
$templateName : string
$data : array<string|int, mixed> = []
$headers : array<string|int, mixed> = []
Return values
array<string|int, mixed>

sendRaw()

Send a simple email without template (plain text or raw HTML).

public sendRaw(string $to, string $subject, string $body[, bool $isHtml = true ][, array<string|int, mixed> $headers = [] ][, array<string|int, mixed> $attachments = [] ]) : bool
Parameters
$to : string
$subject : string
$body : string
$isHtml : bool = true
$headers : array<string|int, mixed> = []
$attachments : array<string|int, mixed> = []
Return values
bool

withFrom()

Set the "From" name and email for the next send via WP filters.

public withFrom(string $email, string $name) : self

Call before send(). Filters are removed after send completes.

Parameters
$email : string
$name : string
Return values
self

getTemplateCandidatePaths()

Returns ordered list of [htmlPath, plainPath|null] pairs to check.

private getTemplateCandidatePaths(string $name) : array<int, array{0: string, 1: null|string}>

Plugin directory is checked first, then theme fallback.

Parameters
$name : string
Return values
array<int, array{0: string, 1: null|string}>
On this page

Search results