2017 © Pedro Peláez
 

library emailing

Send email over rabbitMQ

image

trejjam/emailing

Send email over rabbitMQ

  • Sunday, January 25, 2015
  • by trejjam
  • Repository
  • 1 Watchers
  • 0 Stars
  • 20 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Emailing

Library for, (*1)

  • managing emails
  • their groups
  • send email to group(s)
  • save email to IMAP

Installation

The best way to install Trejjam/Emailing is using Composer:, (*2)

$ composer require trejjam/emailing

Configuration RabbitMq

Look how to configure Kdyby/RabbitMq This extension need only 'rabbitmq.connection', (*3)

extensions:
    rabbitmq: Kdyby\RabbitMq\DI\RabbitMqExtension

rabbitmq:
    connection:
        default:
            host: localhost
            port: 5672
            user: 'guest'
            password: 'guest'
            vhost: '/'

Configuration

.neon, (*4)

extensions:
    emailing: Trejjam\DI\EmailingExtension

emailing:
    tables   : 
        emails      : 
            table : send__emails
            id    : id
            email : email       
        groups      : 
            table    : send__groups
            id       : id
            parentId : parent_id
            name     : name
            type     : 
                name    : type
                options : [public, private]
        group_email : 
            table      : send__group_email
            id         : id
            groupId    : group_id
            emailId    : email_id
            newsletter : 
                name    : newsletter
                options : [enable, disable]
        senders     : 
            table      : send__sender
            id         : id
            email      : email
            configName : config_name
    connect  : 
        default : 
            smtp          : FALSE #TRUE - use SmtpMailer NULL - disable connection FALSE - use SendmailMailer
            host          : NULL
            smtp_port     : NULL
            username      : NULL
            password      : NULL
            secure        : ssl

            imap          : FALSE
            imap_host     : TRUE #TRUE -> use host
            imap_port     : 993
            imap_param    : /imap/ssl/validate-cert #Flags from http:#php.net/manual/en/function.imap-open.php
            imap_username : TRUE #TRUE -> use username
            imap_password : TRUE #TRUE -> use password
        other:
            ...
    rabbitmq : 
        mailer    : 
            templateDir    : '/presenters/templates/'  
            defaultTemplate: 'emails/default.latte'
        imap      : 
            sendFolder : 'Sent.From web'        
        producers : 
            mailer : 
                name       : NULL #NULL -> use mailer 
                connection : default
                exchange   : NULL #NULL -> use mailer
            imap   : 
                name       : NULL #NULL -> use imap
                connection : default
                exchange   : NULL
        consumers : 
            mailer : 
                connection : default
                exchange   : NULL
                queue      : NULL            
            imap   : 
                connection : default
                exchange   : NULL
                queue      : NULL
    cache    :
        use     : TRUE
        name    : emailing
        timeout : 60 minutes

Config

The best way for configuration is using Kdyby/Console, (*5)

$ composer require kdyby/console

Read how to install Kdyby/Console, (*6)

php index.php

After successful installation display:, (*7)

Available commands:
Emailing
    Emailing:imap       Basic IMAP task
    Emailing:groups     Edit groups
    Emailing:install    Install default tables
    help                Displays help for a command
    list                Lists commands

Config database

Create default tables:, (*8)

php index.php Emailing:install

Config imap

List folders:, (*9)

php index.php Emailing:imap [connectionName=default] -l

Add folder:, (*10)

php index.php Emailing:imap [connectionName=default] -c folderName [-l]

Config groups

Add group:, (*11)

php index.php Emailing:groups groupName [parentName] -c [-t type] [-l]

Move group:, (*12)

php index.php Emailing:groups groupName [parentName] -m [-l]

Edit group:, (*13)

php index.php Emailing:groups groupName -t type [-l]

Delete group:, (*14)

php index.php Emailing:groups groupName -r [-l]

List all groups:, (*15)

php index.php Emailing:groups -l

Config senders

Add sender:, (*16)

php index.php Emailing:senders senderEmail [connection=default] -c [-l]

Change connection:, (*17)

php index.php Emailing:senders senderEmail [connection=default] [-l]

Delete sender:, (*18)

php index.php Emailing:senders senderEmail -r [-l]

List all senders:, (*19)

php index.php Emailing:senders -l

Usage

Presenter/Model:, (*20)

    /**
    * @var \Trejjam\Emailing\RabbitMq\Mailer @inject
    */
    public $rabbitMailer;
    /**
     * @var \Trejjam\Emailing\Emails @inject
     */
    public $emails;
    /**
     * @var \Trejjam\Emailing\Groups @inject
     */
    public $groups;
    /**
     * @var \Trejjam\Emailing\Senders @inject
     */
    public $senders;

    function renderDefault() {
        $this->senders->addSender("email@from.ltd");
        $this->senders->addSender("email2@from.ltd", "other");

        $message=$this->rabbitMailer->createEmail();
        $message->setSender("email@from.ltd"); //set from and connection
        $message->setImapSave(TRUE);

        $message->setTo("email@to.ltd");
        $this->rabbitMailer->send($message);
        //send email generated by defaultTemplate, send using default connection, save email to IMAP

        $message->setSender("email2@from.ltd");
        $message->setTemplate("newsletter.latte");
        $message->setImapFolder("Sent.newsletter");
        $message->setImapConnection("default");
        $message->setUnsubscribeEmail("unsubscribe-1@from.ltd");
        $message->setTo("email2@to.ltd");
        $this->rabbitMailer->send($message);
        //send email generated by newsletter.latte, send using 'other' connection, save email to IMAP using 'default'



        $email = $this->emails->addEmail("email@to.ltd");
        $email2 = $this->emails->addEmail("email2@to.ltd");
        $all=$this->groups->addGroup("all");
        $group = $this->groups->addGroup("newsletter", "all");

        $this->emails->addEmailToGroup($email, $group);
        $this->emails->addEmailToGroup($email2, $all);

        foreach ($all->getEmailsRecursive() as $v) {
            dump($v->getEmail()); //email2@to.ltd, email@to.ltd
        }
        foreach ($all->getEmails() as $v) {
            dump($v->getEmail()); //email2@to.ltd
        }
        foreach ($group->getEmails() as $v) {
            dump($v->getEmail()); //email@to.ltd
        }

        dump($this->groups->getGroup("all")->containEmail($email)); //FALSE
        dump($this->groups->getGroup("newsletter")->containEmail($email)); //TRUE
        $this->emails->removeEmail("email@to.ltd", TRUE);
        $this->emails->removeEmail("email2@to.ltd", TRUE);
    }

The Versions

25/01 2015

dev-master

9999999-dev

Send email over rabbitMQ

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jan Trejbal

email rabbitmq nette

29/12 2014

v0.5

0.5.0.0

Send email over rabbitMQ

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jan Trejbal

email rabbitmq nette

28/12 2014

v0.4

0.4.0.0

Send email over rabbitMQ

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jan Trejbal

email rabbitmq nette