Giter Site home page Giter Site logo

mailcenter's Introduction

MailCenter

  1. Initialization
    --

In order to use MailCenter you will need to call Mailing class.

$mailing = new \MailCenter\Mailing($config, $type, $options, $emails);  
$mailing->run();

$config is a stdClass.

Example $config:

$config = new stdClass();  
$config->siteurl = ‘http://www.test.loc’;  
$config->host = ‘localhost’;  
$config->port = ‘3306’;  
$config->dbname = ‘test’;  
$config->username = ‘root’;  
$config->password = ‘root’;  
$config->path = ‘/../mailcenter’;      /*Path to Mailings described in section 2*/
$config->options = array('someVar'=>'data');

$type – is a name of your mailing, it will be used to find Mailing files described in section 2

Example $type:

$type = ‘appsale’;

$options - is an optional array of options that will be made available to DataProvider

Example $options:

$options = array('appId'=>1);

$emails – is an optional array of emails that mailing will be sent to. If $emails is set to null, UserProvider will look for emails in database, using $type attribute to find users signed up for this mailing.

Example $emails:

$emails = array(
    				0=>array(
    					'email'=>'[email protected]',
    					'username'=>'test'
    				)
    			)
OR
$emails = null;

2 Mailings

If MailCenter folder is core of the project itself, then Mailings are specific implementations. Mailings can be located anywhere in your project and are separate from MailCenter core, but path to Mailings folder needs to be specified in $config->path, when initializing MailCenter.

Mailings follow this file\naming structure:

  {mailingFolder}  
    - Data  
      -- {MailingName}Data.php  
    - Mailing  
      -- {MailingName}Mailing.php  
    - Template  
      -- {MailingName}Template.php  

So if you specified $type = 'appsale', like described in section 1, MailCenter would look for AppsaleData.php, AppsaleMailing.php and AppsaleTemplate.php


{MailingName}Data.php

use MailCenter\Data\DataInterface;

class AppsaleData implements DataInterface
{
    /**
     * @param $db \PDO
     * @param array $options
     * @return array
     */
    public static function getData($db, $options)
    {
        $data = ... \*Code to fetch data using $db - PDO object*\

        return $data;
    }
}

{MailingName}Mailing.php

use MailCenter\Mailing\MailingAbstract;
use MailCenter\Template\TemplateProvider;
use MailCenter\Sender\SenderProvider;

class AppsaleMailing extends MailingAbstract
{
    public function getConfig()
    {
        $config = new \stdClass();
        $config->subject = 'Appsale Daily Newsletter';
        $config->storage = TemplateProvider::STORAGE_TYPE_FILE;
        $config->engine = TemplateProvider::ENGINE_TYPE_PHP;
        $config->sender = SenderProvider::TYPE_MANDRILL;

        return $config;
    }
}

Available Senders are - SenderProvider::TYPE_MANDRILL and SenderProvider::TYPE_SENDMAIL


{MailingName}Template.php

An html email template.

mailcenter's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.