Download the PHP package leuffen/template-mailer without Composer

On this page you can find all versions of the php package leuffen/template-mailer. 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 template-mailer

Template-Mailer

Downloads this Month Latest Stable Version Supports PHP 5.4+ Supports PHP 7.0+

This project combines an powerfull but easy-to-use OOP interface to Multipart-Mime-Mails in conjunction with a easy to learn template-language for defining complete multipart-messages within one string. (Including subject, from, other headers, all kinds of message-parts).

Install

Install using composer:

Basic Example

See directory /doc/template/tpl/ for a bunch of working examples. You can life-test the examples with /doc/template/SendTestMail.php against your MailClient / MTA.

Define a template using text-template syntax

Notice: To display the html-content by default it's important, to put the text/html content to the end of the mail

Load the template and send the mail:

That's it

Adding MailParts to a template

Use the apply() method to not just send the mail but return the MailBody:

Add an attachment using the FileAttachment helper class:

or the manual way:

send the mail:

That's it.

Programmatic multipart example

You can use template-mailer to send multipart-mail without any templating directly from your code:

Using the Template Engine

For standard purpose you should use the MailTemplateParser to generate your Mail. But template-mailer can also be used like an OOP Mail Frontend. You'll find mor Information about that topic in the next section.

Security enhancements when using Templates

Defining Templates

Template-Mail uses Text-Template (http://github.com/dermatthes/text-template) Syntax to define your templates.

Template consist of two sections. The header-section...

... followed by one empty line, and the body-section...

... where you define each part of your mail between <mailPart> and </mailPart>.

You don't have to take care about boundaries, additional headers nor correct escaping.

When defining mailPart you can use the attributes defined below to fit your needs:

Attribute Description Allowed values
contentType text/plain, text/html, application/pdf, ...
contentDisposition attachment, inline
contentTransferEncoding Default: 8Bit 8Bit, quoted-printable, base64
charset Default: UTF-8 utf-8, iso-8895-1, ...
fileName Used with contentDispositon="attachment": The filename to display in attachements
token
id Used to reference attached files. If you name it somefile you can reference it <img src="cid:somefile">
skipEncoding If skipEncoding="no" is present, Text-Template will do no own encoding to the contents YES, NO

The MailBody Content-Type

One word to the content-type of the container-mail:

By default, Template-Mailer will set the content-type in de header of the container-mail to multipart/mixed, which allows multiple attachments.

But it will display all attachments.

You can set it to use multipart/alternative by adding the Header

Debugging the context

To see the structure of the data passed to the template just add

to your template. It will output the structure of the context.

Accessing the TextTemplate Parser

To access and configure the TextTemplate Parser use the MailTemplateParser::getTextTemplateParser() method.

Example:

Changing the Deliveryagent to an non local SMTP Server

To change the DeliveryAgent, it must be set in the MailKernel, via the static function SetMailDeliveryAgent The SmtpDeliveryAgent uses the class PHPMailer to send an SMTP Message to the chosen Server

Example:

About

Template-Mailer was written by Matthias Leuffen http://leuffen.de


All versions of template-mailer with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5
text/template Version ~2.3
phpmailer/phpmailer Version ~6.0
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 leuffen/template-mailer contains the following files

Loading the files please wait ....