Skip to content

Framework and library agnostic email sending - a fluid and strict typed interface for email sending

License

Notifications You must be signed in to change notification settings

Phauthentic/email

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Framework and library agnostic Email sending

Software License Scrutinizer Coverage Code Quality

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 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()
  • Log Mailer - for testing, requires a PSR3 compatible logger
  • Null Mailer - for testing

How to use it

Assuming you want to use this library with the Swift mailer:

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:

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('<p>My HTML content</p>');

$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.

Copyright (c) Phauthentic

About

Framework and library agnostic email sending - a fluid and strict typed interface for email sending

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages