Email can be configured in file
config/app.php. It is not
required to define email configuration in config/app.php. Email can be
used without it; just use the respective methods to set all
configurations separately or load an array of configs. Configuration for
Email defaults is created using
config() and
configTransport().
Email Configuration Transport
By defining transports separately from delivery profiles, you can
easily re-use transport configuration across multiple profiles. You can
specify multiple configurations for production, development and testing.
Each transport needs a
className. Valid options are as follows −
- Mail − Send using PHP mail function
- Smtp − Send using SMTP
- Debug − Do not send the email, just return the result
You can add custom transports (or override existing transports) by adding the appropriate file to
src/Mailer/Transport.Transports should be named
YourTransport.php, where
'Your' is the name of the transport. Following is the example of Email configuration transport.
Example
'EmailTransport' => [
'default' => [
'className' => 'Mail',
// The following keys are used in SMTP transports
'host' => 'localhost',
'port' => 25,
'timeout' => 30,
'username' => 'user',
'password' => 'secret',
'client' => null,
'tls' => null,
'url' => env('EMAIL_TRANSPORT_DEFAULT_URL', null),
],
],
Email Delivery Profiles
Delivery profiles allow you to predefine various properties about
email messages from your application and give the settings a name. This
saves duplication across your application and makes maintenance and
development easier. Each profile accepts a number of keys. Following is
an example of Email delivery profiles.
Example
'Email' => [
'default' => [
'transport' => 'default',
'from' => 'you@localhost',
],
],
No comments:
Post a Comment