yiisoft/mailer

Sending email abstraction

6.0.0 2024-10-18 07:32 UTC

This package is auto-updated.

Last update: 2024-11-18 07:39:34 UTC


README

Yii

Yii Mailer


Latest Stable Version Total Downloads Build status Code Coverage Mutation testing badge static analysis psalm-level type-coverage

The package provides abstraction for sending emails via mailer and message interfaces. Actual mail sending is provided by separate interchangeable packages.

The following mailers are available out of the box:

  • FileMailer - writes message to files instead of actually sending email.
  • StubMailer - keeps messages in memory and doesn't send them.
  • NullMailer - does nothing.

Yii Mailer extensions:

Requirements

  • PHP 8.1 or higher.

Installation

The package could be installed with Composer:

composer require yiisoft/mailer

General usage

The following code can be used to send an email:

/**
 * @var \Yiisoft\Mailer\MailerInterface $mailer
 */

$message = (new \Yiisoft\Mailer\Message())
    ->withFrom('from@domain.com')
    ->withTo('to@domain.com')
    ->withSubject('Message subject')
    ->withTextBody('Plain text content')
    ->withHtmlBody('<b>HTML content</b>');
    
$mailer->send($message);

Documentation

If you need help or have a question, the Yii Forum is a good place for that. You may also check out other Yii Community Resources.

License

The Yii Mailer is free software. It is released under the terms of the BSD License. Please see LICENSE for more information.

Maintained by Yii Software.

Support the project

Open Collective

Follow updates

Official website Twitter Telegram Facebook Slack