Download the PHP package silktide/templated-emailer without Composer

On this page you can find all versions of the php package silktide/templated-emailer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package templated-emailer

Build Status Code Climate Test Coverage

Templated emailer

This library simply ties together Symfony's powerful templating engine with the flexibility of Swiftmailer, allowing you to send templated emails easily.

Setup

Without DI

If you're not using DI (or don't know what DI is) there is a helpful factory to create the mailer:

$emailer = \Silktide\TemplatedEmailer\TemplatedEmailerFactory::create('/path/to/templates');

The only required argument is the path to the folder containing your email templates (see Creating a template below).

By default, the factory will set up the class to use PHP's mail() function to send your mail and Symfony's PhpEngine for templating. You can optionally provide a Swiftmailer transport class as the second argument if you want to use a different transport, e.g. SMTP. Here's an example of using an alternative transport:

$transport = \Swift_SmtpTransport::newInstance('smtp.example.org', 25)
            ->setUsername('your username')
            ->setPassword('your password');
$emailer =  \Silktide\TemplatedEmailer\TemplatedEmailerFactory::create('/example', $transport);

Dependency injection / manual instantiation

The TemplatedEmailer class just requires two arguments, a Symfony template engine and an instance of Swift_Mailer:

/**
* @var \Symfony\Component\Templating\EngineInterface
*/
$templateEngine;

/**
* @var \Swift_Mailer
*/
$emailClient;

$emailer = new \Silktide\TemplatedEmailer\TemplatedEmailer($templateEngine, $emailClient);

Creating a template

Templates are using Symfony's well documented template library. Here's a very basic example:

<h1>An email from myApp</h1>
<p>Dear </p>
<p>

The variables in the message are passed through as an array to the send() method (see usage below).

Usage

Before any emails can be sent, you must set a sender:

$emailer->setSender('[email protected]', 'Postman Pat');

Sending an email now just requires a recipient, subject, template filename and context:

$this->mailer->send(
    '[email protected]',
    'Jess the black and white cat',
    'anEmail.php',
    [
        'recipientName' => 'Mrs Goggins',
        'message' => 'Hello!'
    ]
);

The recipient can also have a name set by using an array in the format ['[email protected]' => 'Friendly Name']:

$this->mailer->send(
    ['[email protected]' => 'Mrs Goggins'],
    'Jess the black and white cat',
    'anEmail.php',
    [
        'recipientName' => 'Mrs Goggins',
        'message' => 'Hello!'
    ]
);

All versions of templated-emailer with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5.0
swiftmailer/swiftmailer Version ^5.4
symfony/templating Version ^2.7
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package silktide/templated-emailer contains the following files

Loading the files please wait ....