piedweb/tiny-maillist-builder

This package is abandoned and no longer maintained. The author suggests using the piedweb/tiny-maillist-builder package instead.

1.0.0 2019-03-08 15:19 UTC

This package is auto-updated.

Last update: 2022-02-24 23:57:33 UTC


README

Open Source Package

Tiny MailList Builder...

... for almost hand-held newsletter.

Install

Using composer : Packagist

$ composer require piedweb/tiny-maillist-builder

Usage

This example demonstrate the possible usage on a static website on the one hand (where we want the user suscribe to our email list), and on the other hand, a dynamic server with a specific subdomain (eg: mail-list.example.tld).

The dynamic server will host our package and a simple controller like :

include 'vendor/autoload.php';

header("Access-Control-Allow-Origin: *");

if ($_SERVER['REQUEST_METHOD'] === 'POST')
{
    $list = new TinyMailListBuilder(['piedweb'], 'list');
    if ($list->add(trim($_POST['email'] ?? ''), $_POST['list'] ?? '')) {
        exit('OK');
    } else {
        exit('EVER');
    }

} else {
    header("HTTP/1.1 401 Unauthorized");
    exit('ERROR');
}

The static website will integrate in his front end something like :

import { tinyMailListBuilder } from "~/vendor/piedweb/tiny-maillist-builder/js/TinyMailListBuilder.js";

var form = document.getElementById("newsletter");
var config_list = 'piedweb';

form.addEventListener("submit", function(evt) {
    evt.preventDefault();
  form.querySelector('input[type="submit"]').value = '...';
  form.querySelector('input[type="submit"]').setAttribute('disabled', 'disabled');
    tinyMailListBuilder(form, function(text) {console.log(text);form.querySelector('input[type="submit"]').value = 'Stored !';});
}, config_list);
<form action="https://mailist.example.tld/" id="newsletter">
  <input type=email placeholder="contact@example.tld">
  <input type=submit >
</form>

Contributing

Please see contributing

Credits

License

The MIT License (MIT). Please see License File for more information.

Latest Version Software License Build Status Quality Score Code Coverage Total Downloads