AddressingTrait
Define the $to, $from, $replyTo, $cc, and $bcc fields to a WorkflowMessage class.
Email addresses may be get or set in any of these formats:
- rfc822 (string): RFC822-style, e.g. 'Full Name user@example.com'
- record (array): Pair of name+email, e.g. ['name' => 'Full Name', 'email' => 'user@example.com']
- records: (array) List of records, keyed sequentially.
Table of Contents
Properties
- $bcc : string|null
- Additional recipients (multiple addresses).
- $cc : string|null
- Additional recipients (multiple addresses).
- $from : string|null
- The email sender (single address).
- $replyTo : string|null
- The email sender's Reply-To (single address).
- $to : string|null
- The primary email recipient (single address).
Methods
- addBcc() : $this
- Add another "BCC:" address.
- addCc() : $this
- Add another "CC:" address.
- getBcc() : array<string|int, mixed>|string
- Get the list of "Bcc:" addresses.
- getCc() : array<string|int, mixed>|string
- Get the list of "Cc:" addresses.
- getFrom() : array<string|int, mixed>|string
- Get the "From:" address.
- getReplyTo() : array<string|int, mixed>|string
- Get the "Reply-To:" address.
- getTo() : array<string|int, mixed>|string
- Get the list of "To:" addresses.
- setBcc() : $this
- Set the "BCC:" list.
- setCc() : $this
- Set the "CC:" list.
- setFrom() : $this
- setReplyTo() : $this
- setTo() : $this
- exportExtraEnvelope_toAddress() : void
- Plugin to `WorkflowMessageInterface::export()` and handle toEmail/toName.
- importExtraEnvelope_toAddress() : void
- Plugin to `WorkflowMessageInterface::import()` and handle toEmail/toName.
- formatAddress() : array<string|int, mixed>|string|null
- Convert an address to the desired format.
Properties
$bcc
Additional recipients (multiple addresses).
protected
string|null
$bcc
Ex: '"Foo Bar" foo.bar@example.com, "Whiz Bang" whiz.bang@example.com' Ex: [['name' => 'Foo Bar', 'email' => 'foo.bar@example.com'], ['name' => 'Whiz Bang', 'email' => 'whiz.bang@example.com']]
Tags
$cc
Additional recipients (multiple addresses).
protected
string|null
$cc
Ex: '"Foo Bar" foo.bar@example.com, "Whiz Bang" whiz.bang@example.com' Ex: [['name' => 'Foo Bar', 'email' => 'foo.bar@example.com'], ['name' => 'Whiz Bang', 'email' => 'whiz.bang@example.com']]
Tags
$from
The email sender (single address).
protected
string|null
$from
Ex: '"Foo Bar" foo.bar@example.com'
Tags
$replyTo
The email sender's Reply-To (single address).
protected
string|null
$replyTo
Ex: '"Foo Bar" foo.bar@example.com'
Tags
$to
The primary email recipient (single address).
protected
string|null
$to
Ex: '"Foo Bar" foo.bar@example.com' Ex: ['name' => "Foo Bar", "email" => "foo.bar@example.com"]
The "To:" address is mapped to the "envelope" scope. The existing envelope format treats this as a pair of fields [toName,toEmail]. Consequently, we only support one "To:" address, and it uses a special import/export method.
Methods
addBcc()
Add another "BCC:" address.
public
addBcc(string|array<string|int, mixed> $address) : $this
Parameters
- $address : string|array<string|int, mixed>
-
Ex: '"Foo Bar" foo.bar@example.com' Ex: ['name' => "Foo Bar", "email" => "foo.bar@example.com"] Ex: [['email' => 'first@example.com'], ['email' => 'second@example.com']]
Return values
$thisaddCc()
Add another "CC:" address.
public
addCc(string|array<string|int, mixed> $address) : $this
Parameters
- $address : string|array<string|int, mixed>
-
Ex: '"Foo Bar" foo.bar@example.com' Ex: ['name' => "Foo Bar", "email" => "foo.bar@example.com"] Ex: [['email' => 'first@example.com'], ['email' => 'second@example.com']]
Return values
$thisgetBcc()
Get the list of "Bcc:" addresses.
public
getBcc([string $format = ADDRESS_EXPORT_FMT ]) : array<string|int, mixed>|string
Parameters
- $format : string = ADDRESS_EXPORT_FMT
-
Ex: 'rfc822', 'records', 'record'
Return values
array<string|int, mixed>|string —List of addresses. Ex: 'First first@example.com, second@example.com' Ex: [['name' => 'First', 'email' => 'first@example.com'], ['email' => 'second@example.com']]
getCc()
Get the list of "Cc:" addresses.
public
getCc([string $format = ADDRESS_EXPORT_FMT ]) : array<string|int, mixed>|string
Parameters
- $format : string = ADDRESS_EXPORT_FMT
-
Ex: 'rfc822', 'records', 'record'
Return values
array<string|int, mixed>|string —List of addresses. Ex: 'First first@example.com, second@example.com' Ex: [['name' => 'First', 'email' => 'first@example.com'], ['email' => 'second@example.com']]
getFrom()
Get the "From:" address.
public
getFrom([string $format = ADDRESS_EXPORT_FMT ]) : array<string|int, mixed>|string
Parameters
- $format : string = ADDRESS_EXPORT_FMT
-
Ex: 'rfc822', 'records', 'record'
Return values
array<string|int, mixed>|string —The "From" address. If none set, this will be empty ([]). Ex: '"Foo Bar" foo.bar@example.com' Ex: ['name' => 'Foo Bar', 'email' => 'foo.bar@example.com']
getReplyTo()
Get the "Reply-To:" address.
public
getReplyTo([string $format = ADDRESS_EXPORT_FMT ]) : array<string|int, mixed>|string
Parameters
- $format : string = ADDRESS_EXPORT_FMT
-
Ex: 'rfc822', 'records', 'record'
Return values
array<string|int, mixed>|string —The "From" address. If none set, this will be empty ([]). Ex: '"Foo Bar" foo.bar@example.com' Ex: ['name' => 'Foo Bar', 'email' => 'foo.bar@example.com']
getTo()
Get the list of "To:" addresses.
public
getTo([string $format = ADDRESS_EXPORT_FMT ]) : array<string|int, mixed>|string
Note: This returns only
Parameters
- $format : string = ADDRESS_EXPORT_FMT
-
Ex: 'rfc822', 'records', 'record'
Return values
array<string|int, mixed>|string —Ex: '"Foo Bar" foo.bar@example.com' Ex: ['name' => 'Foo Bar', 'email' => 'foo.bar@example.com']
setBcc()
Set the "BCC:" list.
public
setBcc(string|array<string|int, mixed> $address) : $this
Parameters
- $address : string|array<string|int, mixed>
-
Ex: '"Foo Bar" foo.bar@example.com' Ex: ['name' => "Foo Bar", "email" => "foo.bar@example.com"] Ex: [['email' => 'first@example.com'], ['email' => 'second@example.com']]
Return values
$thissetCc()
Set the "CC:" list.
public
setCc(string|array<string|int, mixed> $address) : $this
Parameters
- $address : string|array<string|int, mixed>
-
Ex: '"Foo Bar" foo.bar@example.com' Ex: ['name' => "Foo Bar", "email" => "foo.bar@example.com"] Ex: [['email' => 'first@example.com'], ['email' => 'second@example.com']]
Return values
$thissetFrom()
public
setFrom(string|array<string|int, mixed> $address) : $this
Parameters
- $address : string|array<string|int, mixed>
-
Ex: '"Foo Bar" foo.bar@example.com' Ex: ['name' => "Foo Bar", "email" => "foo.bar@example.com"]
Return values
$thissetReplyTo()
public
setReplyTo(string|array<string|int, mixed> $address) : $this
Parameters
- $address : string|array<string|int, mixed>
-
Ex: '"Foo Bar" foo.bar@example.com' Ex: ['name' => "Foo Bar", "email" => "foo.bar@example.com"]
Return values
$thissetTo()
public
setTo(string|array<string|int, mixed> $address) : $this
Parameters
- $address : string|array<string|int, mixed>
-
Ex: '"Foo Bar" foo.bar@example.com' Ex: ['name' => "Foo Bar", "email" => "foo.bar@example.com"]
Return values
$thisexportExtraEnvelope_toAddress()
Plugin to `WorkflowMessageInterface::export()` and handle toEmail/toName.
protected
exportExtraEnvelope_toAddress(array<string|int, mixed> &$values) : void
Parameters
- $values : array<string|int, mixed>
Tags
importExtraEnvelope_toAddress()
Plugin to `WorkflowMessageInterface::import()` and handle toEmail/toName.
protected
importExtraEnvelope_toAddress(array<string|int, mixed> &$values) : void
Parameters
- $values : array<string|int, mixed>
Tags
formatAddress()
Convert an address to the desired format.
private
formatAddress(string $newFormat, array<string|int, mixed>|string $mixed) : array<string|int, mixed>|string|null
Parameters
- $newFormat : string
-
Ex: 'rfc822', 'records', 'record'
- $mixed : array<string|int, mixed>|string