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'
string
'both'
string
'html'
string
'text'
array
A copy of the configuration profile for this instance. This copy can be modified with Email::profile().
\Cake\Mailer\AbstractTransport|null
The transport instance to use for sending mail.
\Cake\Mailer\Message
Message instance.
string
Message class name.
\Cake\Mailer\Renderer|null
Email Renderer
Proxy all static method calls (for methods provided by StaticConfigTrait) to Mailer.
Serializes the email object to a value that can be natively serialized and re-used to clone this email instance.
__call(string $method, array $args)
Magic method to forward method class to Email instance.
string
$method Method name.
array
$args Method arguments
$this|mixed
__callStatic(mixed $name, mixed $arguments)
Proxy all static method calls (for methods provided by StaticConfigTrait) to Mailer.
string
$name Method name.
array
$arguments Method argument.
mixed
__clone()
Clone Renderer instance when email object is cloned.
__construct(mixed $config)
Constructor
array|string|null
$config optional Array of configs, or string to load configs from app.php
_logDelivery(array $contents)
Log the email message delivery.
array
$contents The content with 'headers' and 'message' keys.
createFromArray(array $config)
Configures an email instance object from serialized config.
array
$config Email configuration array.
$this
Configured email instance.
deliver(mixed $to, ?string $subject, mixed $message, mixed $config, bool $send)
Static method to fast create an instance of \Cake\Mailer\Email
string|array|null
$to optional Address to send (see Cake\Mailer\Email::to()). 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
string|array|null
$message optional String with message or array with variables to be used in render
string|array
$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\Email
Instance of Cake\Mailer\Email
InvalidArgumentException
flatten(mixed $value)
Converts given value to string
string|array
$value The value to convert
string
getMessage()
Get message instance.
\Cake\Mailer\Message
getProfile()
Gets the configuration profile to use for this instance.
array
getRenderer()
Get email renderer.
\Cake\Mailer\Renderer
getTransport()
Gets the transport.
\Cake\Mailer\AbstractTransport|null
getViewRenderer()
Gets view class for render.
string
getViewVars()
Gets variables to be set on render.
array
jsonSerialize()
Serializes the email object to a value that can be natively serialized and re-used to clone this email instance.
array
Serializable array of configuration properties.
Exception
message(?string $type)
Get generated message (used by transport classes)
string|null
$type optional Use MESSAGE_* constants or null to return the full message as array
string|array
String if type is given, array if type is null
render(mixed $content)
Render email.
string|array|null
$content optional Content array or string
reset()
Reset all the internal variables to be able to send out a new email.
$this
send(mixed $content)
Send an email using the specified content, template and layout
string|array|null
$content optional String with message or array with messages
array
BadMethodCallException
serialize()
Serializes the Email object.
string
setProfile(mixed $config)
Sets the configuration profile to use for this instance.
string|array
$config String with configuration name, or an array with config.
$this
setRenderer(\Cake\Mailer\Renderer $renderer)
Set email renderer.
\Cake\Mailer\Renderer
$renderer Render instance.
$this
setTransport(mixed $name)
Sets the transport.
When setting the transport you can either use the name of a configured transport or supply a constructed transport.
string|\Cake\Mailer\AbstractTransport
$name Either the name of a configured transport, or a transport instance.
$this
LogicException
InvalidArgumentException
setViewRenderer(string $viewClass)
Sets view class for render.
string
$viewClass View class name.
$this
setViewVars(array $viewVars)
Sets variables to be set on render.
array
$viewVars Variables to set for view.
$this
unserialize(mixed $data)
Unserializes the Email object.
string
$data Serialized string.
viewBuilder()
Get view builder.
\Cake\View\ViewBuilder
A copy of the configuration profile for this instance. This copy can be modified with Email::profile().
array
The transport instance to use for sending mail.
\Cake\Mailer\AbstractTransport|null
Message instance.
\Cake\Mailer\Message
Message class name.
string
Email 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.1/class-Cake.Mailer.Email.html