miniframe/mailer-bundle

Mailer bundle for the Miniframe PHP Framework.

v1.0.1 2021-09-20 11:18 UTC

This package is auto-updated.

Last update: 2024-03-25 22:51:29 UTC


README

This is a mailer bundle for the Miniframe PHP Framework.

With this bundle, it's easy to set up outgoing emails from within your PHP application.

build code coverage

How to use

  1. In your existing project, type: composer require miniframe/mailer-bundle
  2. Add the directive below to your config.ini

Example config.ini directives

[framework]
middleware[] = Miniframe\Mailer\Middleware\Mailer

[mailer]
from_name = Sender name
from_email = no-reply@foobar.baz
; Optionally, to use SMTP:
transport = smtp
smtp_hostname = smtp.foobar.baz
smtp_authentication = true
smtp_username = foobar
smtp_port = 587
; SMTP encryption can be TLS, SSL or PLAIN
smtp_encryption = TLS

Place the password in a separate secrets.ini that's in your .gitignore file:

[mailer]
smtp_password = ************************

Now, you can use this in your code:

$recipient = new Recipient('email@example.com', 'Example');
$subject = 'Mail subject';
$mailBody = new Response('<html lang="en"><body><b>HTML</b> mail</body></html>');

$mailer = Registry::get(Mailer::class);
$mailer->sendMail($recipient, $subject, $mailBody);

For Windows Developers

In the bin folder, a few batch files exist, to make development easier.

If you install Docker Desktop for Windows, you can use bin\composer.bat, bin\phpcs.bat, bin\phpunit.bat, bin\phpstan.bat and bin\security-checker.bat as shortcuts for Composer, CodeSniffer, PHPUnit, PHPStan and the Security Checker, without the need of installing PHP and other dependencies on your machine.

The same Docker container and tools are used in Bitbucket Pipelines to automatically test this project.