CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (Github)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 3.1 Red Velvet API

  • Project:
    • CakePHP
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 3.1
      • 6.0
      • 5.4
      • 5.3
      • 5.2
      • 5.1
      • 5.0
      • 4.6
      • 4.5
      • 4.4
      • 4.3
      • 4.2
      • 4.1
      • 4.0
      • 3.10
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Namespaces

  • Global
  • Cake
    • Auth
    • Cache
    • Collection
    • Console
    • Controller
    • Core
    • Database
    • Datasource
    • Error
    • Event
    • Filesystem
    • Form
    • I18n
    • Log
    • Mailer
    • Network
    • ORM
    • Routing
    • Shell
    • TestSuite
    • Utility
    • Validation
    • View

Namespace Mailer

Namespaces

  • Cake\Mailer\Exception
  • Cake\Mailer\Transport

Classes

  • AbstractTransport

    Abstract transport for sending email

  • Email

    CakePHP Email class.

    This class is used for sending Internet Message Format based on the standard outlined in http://www.rfc-editor.org/rfc/rfc2822.txt

    Configuration

    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.

  • Mailer

    Mailer base class.

    Mailer classes let you encapsulate related Email logic into a reusable and testable class.

    Defining Messages

    Mailers make it easy for you to define methods that handle email formatting logic. For example:

    class UserMailer extends Mailer
    {
        public function resetPassword($user)
        {
            $this
                ->subject('Reset Password')
                ->to($user->email)
                ->set(['token' => $user->token]);
        }
    }

    Is a trivial example but shows how a mailer could be declared.

    Sending Messages

    After you have defined some messages you will want to send them:

    $mailer = new UserMailer();
    $mailer->send('resetPassword', $user);

    Event Listener

    Mailers can also subscribe to application event allowing you to decouple email delivery from your application code. By re-declaring the implementedEvents() method you can define event handlers that can convert events into email. For example, if your application had a user registration event:

    public function implementedEvents()
    {
        return [
            'Model.afterSave' => 'onRegistration',
        ];
    }
    
    public function onRegistration(Event $event, Entity $entity, ArrayObject $options)
    {
        if ($entity->isNew()) {
             $this->send('welcome', [$entity]);
        }
    }

    The onRegistration method converts the application event into a mailer method. Our mailer could either be registered in the application bootstrap, or in the Table class' initialize() hook.

Traits

  • MailerAwareTrait

    Provides functionality for loading mailer classes onto properties of the host object.

    Example users of this trait are Cake\Controller\Controller and Cake\Console\Shell.

OpenHub
Pingping
Linode
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (Github)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs