miniframe / mailer-bundle
Mailer bundle for the Miniframe PHP Framework.
Requires
- php: >=7.3
- miniframe/core: ^1.0
- phpmailer/phpmailer: ^6.5
Requires (Dev)
- garrcomm/phpunit-helpers: ^1.0
- phpunit/phpunit: ^9.4
- squizlabs/php_codesniffer: ^3.5
Suggests
- ext-fileinfo: To automatically detect the mime type for mail attachments
Provides
None
Conflicts
None
Replaces
None
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.
How to use
- In your existing project, type:
composer require miniframe/mailer-bundle - 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);
Docker shortcuts
In the bin folder, a few batch files and shell scripts exist, to make development easier.
If you install Docker Desktop for Windows or Docker on Linux,
you can use the scripts in bin (for example bin\composer.bat for Windows or bin/composer.sh for Linux)
to run Bash, Composer, CodeSniffer, PHPUnit, PHPStan and 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.