https://github.com/phauthentic/email
Framework and library agnostic email sending - a fluid and strict typed interface for email sending
https://github.com/phauthentic/email
abstraction adapter email oop php-library php7 wrapper
Last synced: 10 months ago
JSON representation
Framework and library agnostic email sending - a fluid and strict typed interface for email sending
- Host: GitHub
- URL: https://github.com/phauthentic/email
- Owner: Phauthentic
- License: mit
- Created: 2018-11-13T23:25:55.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-08-06T21:30:24.000Z (over 6 years ago)
- Last Synced: 2025-02-22T08:29:33.076Z (about 1 year ago)
- Topics: abstraction, adapter, email, oop, php-library, php7, wrapper
- Language: PHP
- Size: 72.3 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Framework and library agnostic Email sending
[](LICENSE)
[](https://scrutinizer-ci.com/g/Phauthentic/email/)
[](https://scrutinizer-ci.com/g/Phauthentic/email/)
Most email libraries are old and don't have what we consider a good interface, also we had the case that we needed to switch the underlying implementation. This library makes it both very convenient, it offers a [fluid](https://en.wikipedia.org/wiki/Fluent_interface) and strict typed interface to build emails and sending them through any mailer you want.
This library mostly implements just an email entity that is passed to a mailer that takes care of the actual email sending. It shouldn't be possible to create and send an email with an invalid state with this library.
## Mailers supported out of the box
* Swift Mailer (recommended)
* PHPMailer
Other included mailers:
* mail() Mailer - a *very* simple implementation using [mail()](http://php.net/manual/de/function.mail.php)
* Log Mailer - for testing, requires a [PSR3](https://github.com/php-fig/log) compatible logger
* Null Mailer - for testing
## How to use it
Assuming you want to use this library with the Swift mailer:
```sh
composer require phauthentic/email
composer require swiftmailer/swiftmailer
```
**Be aware that the library doesn't come with a default mailer library dependency! You MUST choose one that is supported!**
A *simple* example:
```php
use Phauthentic\Email\Email;
use Phauthentic\Email\EmailAddress;
use Phauthentic\Email\Mailer\SwiftMailer;
use Swift_Mailer;
use Swift_SmtpTransport;
$email = (new Email());
->setSender(new EmailAddress('me@test.com', 'Senders Name'))
->addReceiver(new EmailAddress('you@test.com'))
->setSubject('A test')
->setTextContent('My text email')
->setHtmlContent('
My HTML content
');
$mailer = new SwiftMailer(new Swift_Mailer(new Swift_SmtpTransport()));
$mailer->send($email);
$mailer->send($anotherEmail);
$mailer->send($oneMore);
```
## Missing a feature?
Please open a feature type issue on Github with a detailed description and with an example of how to archive what you want in your mailer. Or even better: Create a pull request!
## Copyright & License
Licensed under the [MIT license](LICENSE.txt).
Copyright (c) [Phauthentic](https://github.com/Phauthentic)