2017 © Pedro PelĂĄez
 

library mail-center

Mail center

image

ikknd/mail-center

Mail center

  • Friday, January 17, 2014
  • by ikknd
  • Repository
  • 1 Watchers
  • 0 Stars
  • 27 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

MailCenter

1. Initialization

In order to use MailCenter you will need to call Mailing class., (*1)

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

$config is a stdClass., (*2)

Example $config:, (*3)

$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, (*4)

Example $type:, (*5)

$type = ‘appsale’;

$options - is an optional array of options that will be made available to DataProvider, (*6)

Example $options:, (*7)

$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., (*8)

Example $emails:, (*9)

$emails = array(
                    0=>array(
                        'email'=>'test@test.com',
                        '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., (*10)

Mailings follow this file\naming structure:, (*11)

  {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, (*12)


{MailingName}Data.php, (*13)

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, (*14)

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, (*15)


{MailingName}Template.php, (*16)

An html email template., (*17)

The Versions

17/01 2014

dev-master

9999999-dev https://github.com/ikknd/MailCenter.git

Mail center

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

mail mandrill templates

11/12 2013

dev-readme

dev-readme https://github.com/ikknd/MailCenter.git

Mail center

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

mail mandrill templates