atk4 / ui

Robust and easy to use PHP Framework for Web Apps
https://atk4-ui.readthedocs.io
MIT License
443 stars 106 forks source link

[Addon] - Implement "Outbox", email sending functionality #309

Closed romaninsh closed 2 years ago

romaninsh commented 6 years ago

Bountysource

Outbox add-on offers a modern implementation of sending user messages (email, SMS, push notification, etc) through "Gateways".

The main idea is to have add-on which could handle two-way communications with mail delivery provider:

Optional features:

To provide cross-gateway transparency we also need to use a good 3rd party framework. Here are some candidates:

Example Admin UI:

screen shot 2018-01-04 at 11 54 05

Send a message UI: 5f757471f9599cacb84199aad4119668da414a21_1_690x412

Email field:

6b4a7c32f4b335a45d412625d5e9fb5870690df2

Current status: not started

romaninsh commented 6 years ago

Outbox Model: (WARNING - USES LEGACY SYNTAX)

class Outbox extends Model {
    public $table = 'outbox';
    function init()
    {
        parent::init();
        $this->hasOne('User')->editable(false);

        $this->addField('slug'); // short text describing message
        $this->addField('message')->type('text');
        $this->addField('email');
        $this->addField('name');
        $this->addField('tags')->type('text');
        $this->addField('is_sent')->type('boolean');
        $this->addField('is_urgent')->type('boolean');

        $this->addField('error')->type('text');
        $this->addField('is_bounced')->type('boolean');

        // Instantiate Mandrill here, used in two function now
        $this->mandrill = new Mandrill($this->app->getConfig('mandril/key'));
        $this->tags_array = [
            'FromServer' => $this->app->pm->base_url,
            'Site' => get_class($this->app) == 'App_CLI' ? 'Command Line' : $this->app->getFrontendURL()
        ];
    }

    function new($slug, $template, $tags = []) {
    }

    function send() {
    }
}

The way to integrate would be by adding this into your User class:

$this->hasMany('Messages', new Outbox());

To use:

$user->ref('Messages')
    ->new('password reminder', 'reminder', ['link'=>$link])
    ->send();
mvorisek commented 2 years ago

this is not akt4/ui problem, should be solved in https://github.com/atk4/outbox