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
Requires
- php: ~7.1
Requires (Dev)
- phpunit/phpunit: >=7.0
- squizlabs/php_codesniffer: ^3.0
This package is auto-updated.
Last update: 2022-02-24 23:57:33 UTC
README
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.