Skip to content
This repository was archived by the owner on Aug 16, 2022. It is now read-only.
/ php-email Public archive

A domain model for describing emails

License

Notifications You must be signed in to change notification settings

quartzy/php-email

Folders and files

NameName
Last commit message
Last commit date

Latest commit

8f29f61 · Dec 19, 2018

History

37 Commits
Jul 30, 2018
Jul 30, 2018
Feb 18, 2018
Feb 18, 2018
Feb 18, 2018
Jul 30, 2018
Feb 18, 2018
Dec 19, 2018
Jul 25, 2017
Jul 25, 2017
Feb 10, 2017
Feb 19, 2018
Feb 11, 2018
Jul 25, 2017

Repository files navigation

Php-Email

Latest Version on Packagist Total Downloads Software License Build Status Coverage Status Style Status Scrutinizer Code Quality

This is a domain-driven library for defining emails in PHP.

Php Email brings three major benefits over other similar libraries:

  1. Focusing on new versions of PHP. By using the newer versions of PHP (5.6+) we can leverage great features such as splat parameters and better type hinting.
  2. Focusing on only the email, instead of transmission. In a domain-driven world, emails can and should exist separately from the delivery mechanism. By separating these concerns, this library decreases the size and complexity of the domain, while giving developers greater flexibility in how they use the library.
  3. Flexible content definitions. Emails have gone from a simple text string to highly stylized HTML to now just being templates stored in third-party services. Existing libraries do not provide enough flexibility to support everything developers need. Php Email attempts to correct this by creating guidelines for possible email content, but also allowing developers to define what they need.

Install

With Composer

composer require quartzy/php-email

Usage

Building an email with HTML and text content would look like:

<?php

use PhpEmail\Attachment\FileAttachment;
use PhpEmail\EmailBuilder;
use PhpEmail\Content\SimpleContent;

$email = EmailBuilder::email()
    ->withSubject('Welcome!')
    ->withContent(SimpleContent::text('Start your free trial now!!!'))
    ->from('me@test.com')
    ->to('you@yourbusiness.com')
    ->cc('cc@test.com')
    ->bcc('bcc@test.com')
    ->replyTo('reply.to@test.com')
    ->attach(new FileAttachment('/path/to/my/file.txt'))
    ->build();

Sending a templated email:

<?php

use PhpEmail\EmailBuilder;
use PhpEmail\Content\TemplatedContent;

$content = new TemplatedContent('my_templates_id', ['firstName' => 'Billy']);

$email = EmailBuilder::email()
    ->withSubject('Welcome!')
    ->withContent($content)
    ->from('me@test.com')
    ->to('you@yourbusiness.com')
    ->build();

Change log

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING and CONDUCT for details.

Security

If you discover any security related issues, please email opensource@quartzy.com instead of using the issue tracker.

Credits

License

The Apache License, v2.0. Please see License File for more information.

About

A domain model for describing emails

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages