linyows / notionslot
Notionslot stores messages in database on Notion for email notifications.
v0.3.0
2022-08-06 07:43 UTC
Requires (Dev)
- mockery/mockery: ^1.5
- phpunit/phpunit: ^9.5
This package is not auto-updated.
Last update: 2025-02-15 22:40:30 UTC
README
Notionslot stores messages in database on Notion for email notifications. It is supposed to be used in the contact form of web hosting.
Usage
API mode:
use \Notionslot\Slot; $config = [ 'notion_token' => 'secret_**********************************', 'notion_db_id' => '123456aa-bc12-1234-5678-0987654321aa', 'site_domain' => 'foo.example', 'site_name' => 'My Foo', 'notify_to' => 'me@foo.example', 'reply_to' => 'hello@foo.example', 'mail_from' => 'noreply@foo.example', ]; $data = array_merge($_POST, ['ip' => $_SERVER['REMOTE_ADDR']]); echo Slot::api($config, $_SERVER, $data);
Library mode:
use \Notionslot\Slot; $config = [ 'notion_token' => 'secret_**********************************', 'notion_db_id' => '123456aa-bc12-1234-5678-0987654321aa', 'site_domain' => 'foo.example', 'site_name' => 'My Foo', 'notify_to' => 'me@foo.example', 'reply_to' => 'hello@foo.example', 'mail_from' => 'noreply@foo.example', ]; $data = array_merge($_POST, ['ip' => $_SERVER['REMOTE_ADDR']]); $res = [ 'ok' => true, 'errors' => [], ]; $slot = new Slot($config); if ($slot->sendHeader($_SERVER)->setData($data)->isValid()) { $notionRes = $slot->notify()->reply()->save(); } else { http_response_code(422); $res = [ 'ok' => false, 'errors' => $slot->errors(), ]; } echo json_encode($res);
Installation
The recommended way to install Guzzle is through Composer.
$ composer require linyows/notionslot
Configuration
Please specify notion token, website domain, mail from, reply to, etc by config.
Custom
The default Notion databse property names are Full name(title)
, Email address(email)
, IP(rich_text)
.
You can change the property name and type from the settings.