CakePHP Email class.
This class is used for sending Internet Message Format based on the standard outlined in https://www.rfc-editor.org/rfc/rfc2822.txt
Configuration for Email is managed by Email::config() and Email::configTransport(). Email::config() can be used to add or read a configuration profile for Email instances. Once made configuration profiles can be used to re-use across various email messages your application sends.
string '/^((?:[\\p{L}0-9.!#$%&\'*+\\/=?^_`{|}~-]+)*@[\\p{L}0-9-._]+)$/ui' Holds the regex pattern for email validation
string 'both'
Type of message - BOTH
string 'html'
Type of message - HTML
string 'text'
Type of message - TEXT
array<string, mixed>A copy of the configuration profile for this instance. This copy can be modified with Email::profile().
Cake\Mailer\AbstractTransport|nullThe transport instance to use for sending mail.
Cake\Mailer\MessageMessage instance.
stringMessage class name.
Cake\Mailer\Renderer|nullEmail Renderer
Magic method to forward method class to Email instance.
Proxy all static method calls (for methods provided by StaticConfigTrait) to Mailer.
Clone Renderer instance when email object is cloned.
Constructor
Magic method used for serializing the Email object.
Magic method used to rebuild the Email object.
Log the email message delivery.
Configures an email instance object from serialized config.
Static method to fast create an instance of \Cake\Mailer\Email
Converts given value to string
Get message instance.
Gets the configuration profile to use for this instance.
Get email renderer.
Gets the transport.
Gets view class for render.
Gets variables to be set on render.
Serializes the email object to a value that can be natively serialized and re-used to clone this email instance.
Get generated message (used by transport classes)
Render email.
Reset all the internal variables to be able to send out a new email.
Send an email using the specified content, template and layout
Serializes the Email object.
Sets the configuration profile to use for this instance.
Set email renderer.
Sets the transport.
Sets view class for render.
Sets variables to be set on render.
Unserializes the Email object.
Get view builder.
__call(string $method, array $args): $this|mixed
Magic method to forward method class to Email instance.
string $method Method name.
array $args Method arguments
$this|mixed__callStatic(string $name, array $arguments): mixed
Proxy all static method calls (for methods provided by StaticConfigTrait) to Mailer.
string $name Method name.
array $arguments Method argument.
mixed__clone(): void
Clone Renderer instance when email object is cloned.
void__construct(array<string, mixed>|string|null $config = null)
Constructor
array<string, mixed>|string|null $config optional Array of configs, or string to load configs from app.php
__serialize(): array
Magic method used for serializing the Email object.
array__unserialize(array $data): void
Magic method used to rebuild the Email object.
array $data Data array.
void_logDelivery(array<string, string> $contents): void
Log the email message delivery.
array<string, string> $contents The content with 'headers' and 'message' keys.
voidcreateFromArray(array<string, mixed> $config): $this
Configures an email instance object from serialized config.
array<string, mixed> $config Email configuration array.
$thisdeliver(array|string|null $to = null, string|null $subject = null, array|string|null $message = null, array<string, mixed>|string $config = 'default', bool $send = true): Cake\Mailer\Email
Static method to fast create an instance of \Cake\Mailer\Email
array|string|null $to optional Address to send ({@see \Cake\Mailer\Email::setTo()}). If null, will try to use 'to' from transport config
string|null $subject optional String of subject or null to use 'subject' from transport config
array|string|null $message optional String with message or array with variables to be used in render
array<string, mixed>|string $config optional String to use Email delivery profile from app.php or array with configs
bool $send optional Send the email or just return the instance pre-configured
Cake\Mailer\EmailInvalidArgumentExceptionflatten(array<string>|string $value): string
Converts given value to string
array<string>|string $value The value to convert
stringgetMessage(): Cake\Mailer\Message
Get message instance.
Cake\Mailer\MessagegetProfile(): array<string, mixed>
Gets the configuration profile to use for this instance.
array<string, mixed>getRenderer(): Cake\Mailer\Renderer
Get email renderer.
Cake\Mailer\RenderergetTransport(): Cake\Mailer\AbstractTransport|null
Gets the transport.
Cake\Mailer\AbstractTransport|nullgetViewRenderer(): string
Gets view class for render.
stringgetViewVars(): array<string, mixed>
Gets variables to be set on render.
array<string, mixed>jsonSerialize(): array
Serializes the email object to a value that can be natively serialized and re-used to clone this email instance.
arrayExceptionmessage(string|null $type = null): array|string
Get generated message (used by transport classes)
string|null $type optional Use MESSAGE_* constants or null to return the full message as array
array|stringrender(array<string>|string|null $content = null): void
Render email.
array<string>|string|null $content optional Content array or string
voidreset(): $this
Reset all the internal variables to be able to send out a new email.
$thissend(array<string>|string|null $content = null): array
Send an email using the specified content, template and layout
array<string>|string|null $content optional String with message or array with messages
arrayBadMethodCallExceptionserialize(): string
Serializes the Email object.
stringsetProfile(array<string, mixed>|string $config): $this
Sets the configuration profile to use for this instance.
array<string, mixed>|string $config String with configuration name, or an array with config.
$thissetRenderer(Cake\Mailer\Renderer $renderer): $this
Set email renderer.
Cake\Mailer\Renderer $renderer Render instance.
$thissetTransport(Cake\Mailer\AbstractTransport|string $name): $this
Sets the transport.
When setting the transport you can either use the name of a configured transport or supply a constructed transport.
Cake\Mailer\AbstractTransport|string $name Either the name of a configured transport, or a transport instance.
$thisLogicExceptionInvalidArgumentExceptionsetViewRenderer(string $viewClass): $this
Sets view class for render.
string $viewClass View class name.
$thissetViewVars(array<string, mixed> $viewVars): $this
Sets variables to be set on render.
array<string, mixed> $viewVars Variables to set for view.
$thisunserialize(string $data): void
Unserializes the Email object.
string $data Serialized string.
voidviewBuilder(): Cake\View\ViewBuilder
Get view builder.
Cake\View\ViewBuilderA copy of the configuration profile for this instance. This copy can be modified with Email::profile().
array<string, mixed>The transport instance to use for sending mail.
Cake\Mailer\AbstractTransport|nullMessage instance.
Cake\Mailer\MessageMessage class name.
stringEmail Renderer
Cake\Mailer\Renderer|null
© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/4.4/class-Cake.Mailer.Email.html