Appearance
Recipients are how Notifier determines routing for notifications to a channel and transport.
Internally, all recipients are PHP objects implementing \Symfony\Component\Notifier\Recipient\RecipientInterface
. Depending on which channels a recipient wishes to support, it must implement the associated channel-specific interfaces. A recipient can also implement multiple interfaces simultaneously if the recipient can receive notifications in multiple channels.
These are the interfaces provided by Symfony:
Email recipients
An object implementing \Symfony\Component\Notifier\Recipient\EmailRecipientInterface
.
php
interface EmailRecipientInterface extends RecipientInterface {
public function getEmail(): string;
}
This interfaces requires the getEmail
method . This method must always return a valid email. If a recipient doesn't support or have an email (empty values such as empty-string
, NULL
, FALSE
), then a recipient must not be produced.
SMS recipients
An object implementing \Symfony\Component\Notifier\Recipient\SmsRecipientInterface
.
php
interface SmsRecipientInterface extends RecipientInterface {
public function getPhone(): string;
}
This interface requires the getPhone
method . This method must always return a valid phone number accepted by your SMS service. Some services require local phone numbers, E164, or other format. Check in with your services' API documentation for more detail.
If a recipient doesn't support or have a phone number (empty values such as empty-string
, NULL
, FALSE
), then a recipient must not be produced.
Other channel recipients
Other channel services, like chat channels: Discord, Mastodon, Slack, Telegram, Twitter (X), Microsoft Teams, Bluesky, and others do not have a specific recipient interface, use \Symfony\Component\Notifier\Recipient\RecipientInterface
instead.