Skip to content
Easily send e-mails to clients from data source using templates and data
Branch: master
Clone or download
Pull request Compare This branch is 38 commits behind plumthedev:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs
src
tests
.gitignore
.php_cs
.travis.yml
LICENSE
composer.json
readme.md

readme.md

personalized - Send personalized emails from templates.

downloads count issues count Build Status
GitHub repo size License PHP from Packagist

personalized is a PHP library with which you can easily send e-mails to clients from data source using templates. Templates uses variables to easily replace with real data. personalized can send mail directly from your mailbox using PHPMailer.

You can get data from:

  • CSV files
  • MySQL Database

Requirements

  • PHP >= 7.0

Installation

$ composer require plumthedev/personalized

Usage

Below you can find some useful examples with description of library usage.

personalized have full documentation with Getting Started and Guide and API reference, here.

Templates

Templates is a HTML documents with variables which allows to personalize mail message for recipient.

<h1>Hello %{name}</h1>

personalized easily supports personalize mails.

<?php
    // require autoload and prepare $config
    
    $p = new Presonalized($config);
    
    $p->data->each(function($client){
        global $personalized;        
        
        echo $personalized->template->personalize($client);
    });

Variables are wrapped in %{} and their names come from the data source tables titles.

Data

Data can be provided from CSV files and MySQL databases. You can easily manage provided data like filtering, getting by row or loop.

<?php
    // require autoload and prepare $config
    
    $p = new Presonalized($config);
    
    $scoreBigEnough = $p->data->filter(function($client){
        return $client['score'] > 10;
    });

Data is a class which contains some useful methods to manage data.

Mail

You can sends mail using PHPMailer which is the best mail support PHP library. Can it be better?

<?php
    // require autoload and prepare $config
    
    $personalized = new Personalized($config);
    
    $personalized->data->each(function($client){
        
        // $personalized is located globally so we need to declare use global $personalized
        global $personalized;
        
        // now personalize template and save result to variable
        $personalizedMailTemplate = $personalized->template->personalize($client);
        
        // set body of message and add recipient
        $personalized->mail->setBody($personalizedMailTemplate);
        $personalized->mail->addAddress($client['email'], $client['name']);
        
        // send mail!
        $personalized->mail->send();            
    });

Credits

I want to thanks:

  • supergrecko - Thanks you for excellent feedback about system requirements and support with this!

Library in under development

Currently working on 1.0.0 release. If you want to contribute, I would be grateful!

You can’t perform that action at this time.