Skip to content
Library to send e-mails over different transports and protocols (like SMTP and IMAP) using immutable messages and streams. Also includes SMTP server.
Branch: master
Clone or download
Latest commit a2e3ee6 Feb 18, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
doc
example
src Allow special characters in filenames Feb 18, 2019
test
.appveyor.yml
.gitattributes reply to and forward messages, includes quoted original message (#50) Apr 3, 2018
.gitignore CS (#46) Mar 4, 2018
.php_cs.dist CS (#46) Mar 4, 2018
.phpstan.test.neon
.scrutinizer.yml add scrutinizer config May 26, 2017
.travis.yml
CHANGELOG.md modify changelog Feb 18, 2019
LICENSE move project towards public repository May 24, 2017
README.md add feature of replying, forwarding and quoting Apr 3, 2018
composer.json use SPDX license Mar 5, 2018
phpunit.xml move project towards public repository May 24, 2017

README.md

Genkgo/Mail - Modern PHP 7.1+ Mail Library

Latest Version Build Status Build Status Scrutinizer Code Quality Code Coverage

While analyzing what mail library to use when refactoring a code base, we discovered that the available ones are mostly legacy libraries. Some do not use namespaces and every library we encountered was merely a collection of scalar property bags than objects using encapsulation. Although we used these libs with joy in the past, they do not meet current quality standards. So, we built a new and better library according to modern programming principles.

Use this if you want to send e-mails over different transports and protocols using immutable messages and streams.

Send message quick and easy

$message = (new MessageBodyCollection('<html><body><p>Hello World</p></body></html>'))
    ->withAttachment(new FileAttachment('/order1.pdf', new ContentType('application/pdf')))
    ->createMessage()
    ->withHeader(new Subject('Hello World'))
    ->withHeader(From::fromEmailAddress('from@example.com'))
    ->withHeader(To::fromSingleRecipient('to@example.com', 'name'))
    ->withHeader(Cc::fromSingleRecipient('cc@example.com', 'name'));

$transport = new SmtpTransport(
    ClientFactory::fromString('smtp://user:pass@host/')->newClient(),
    EnvelopeFactory::useExtractedHeader()
);

$transport->send($message);

Install using composer

$ composer require genkgo/mail

Features

  • Use SMTP or mail() to send messages
  • Use IMAPv4 to read messages from your mailbox (no extension required)
  • Create replies and forward messages, including quoting of original message
  • Queue messages when transport fails
  • Automatically connects and reconnects after interval to SMTP server
  • Automatically generate alternative text for formatted messages
  • Optimal encoded headers, so no excessive (Q/B) encoded headers
  • Optimal encoded multipart messages
  • Only streams and connections are mutable
  • Messages and actors are immutable
  • Value objects protect against invalid states
  • Streams make sure the library has a low memory burden
  • Many objects but still easy API
  • 90%+ test coverage
  • Uses highest PHPStan detection level
  • Only uses TLS < 1.2 if not otherwise possible
  • Discourages SSL
  • DKIM signed message
  • Security is highly prioritized
  • SMTP server for testing purposes
  • Great RFC compliance
  • Cast messages to valid string source
  • Library has no external dependencies (but uses intl extension)
  • Only PHP 7.1 and up

Upcoming features

  • Encrypted and signed messages

Not planned

The following features are not planned for development by the owners, but could become part of the library when initiative is taken by the community.

  • POP Support
  • Mailbox abstraction layer

Documentation

RFC-compliance

This library tends to be as compliant with e-mail RFCs as possible. It should be compliant with the following RFCs.

Credits

This library was not able to exist without Zend/Mail and PHPMailer.

You can’t perform that action at this time.