remp / crm-remp-mailer-module
CRM Mailer Module
Installs: 34 768
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 8
Forks: 3
Open Issues: 2
Requires
- php: ^8.1
- dev-master
- 3.5.0
- 3.4.0
- 3.3.0
- 3.2.0
- 3.1.0
- 3.0.0
- 2.11.0
- 2.10.0
- 2.9.0
- 2.8.0
- 2.7.0
- 2.6.0
- 2.5.0
- 2.4.0
- 2.3.0
- 2.2.0
- 2.1.1
- 2.1.0
- 2.0.0
- 1.2.0
- 1.1.0
- 1.0.0
- 1.0.0-beta2
- 1.0.0-beta1
- 0.39.0
- 0.38.0
- 0.37.0
- 0.36.0
- 0.35.0
- 0.34.0
- 0.33.0
- 0.32.0
- 0.31.0
- 0.30.0
- 0.29.1
- 0.29.0
- 0.28.0
- 0.27.0
- 0.26.0
- 0.25.0
- 0.24.0
- 0.23.0
- 0.22.0
- 0.21.0
- 0.20.1
- 0.20.0
- 0.18.0
- 0.15.0
This package is auto-updated.
Last update: 2024-10-25 12:18:59 UTC
README
REMP Mailer Module is an integration module connecting CRM with REMP Mailer.
Module adds listener for NotificationEvent
to send emails, and attaches widgets to allow users/admins to configure newsletter subscriptions and to see logs of all sent emails in administration.
Installing module
We recommend using Composer for installation and update management.
composer require remp/crm-remp-mailer-module
Enabling and configuring module
Add installed extension to your app/config/config.neon
file.
extensions: remp_mailer: Crm\RempMailerModule\DI\RempMailerModuleExtension
When added, you need to provide URL of REMP Mailer instance and API token that CRM should use to communicate with Mailer.
Amend your configuration file and replace the example values with real ones:
remp_mailer: # Base URL where mailer is hosted. host: http://mailer.remp.press # API token to communicate with Mailer. By default the token can be acquired in REMP SSO. api_token: abcdef123456789
If the configuration is incomplete, initialization will log an error to your configured logger and won't enable the module in CRM.
When everything is ready, make sure you update CRM internal configuration by running following commands (they should always be part of your release process):
php bin/command.php api:generate_access
php bin/command.php application:seed
Configurable services
You can disallow subscription to newsletters for users which haven't been confirmed yet (based on users.confirmed_at
DB column). The feature is disabled by default and you can enable it by adding following snippet to your config.neon
:
services: mailerMailerConfig: setup: - setSubscribeOnlyConfirmedUser(true)
API documentation
All examples use http://crm.press
as a base domain. Please change the host to the one you use
before executing the examples.
All examples use XXX
as a default value for authorization token, please replace it with the
real tokens:
- API tokens. Standard API keys for server-server communication. It identifies the calling application as a whole.
They can be generated in CRM Admin (
/api/api-tokens-admin/
) and each API key has to be whitelisted to access specific API endpoints. By default the API key has access to no endpoint. - User tokens. Generated for each user during the login process, token identify single user when communicating between
different parts of the system. The token can be read:
- From
n_token
cookie if the user was logged in via CRM. - From the response of
/api/v1/users/login
endpoint - you're free to store the response into your own cookie/local storage/session.
- From
API responses can contain following HTTP codes:
If possible, the response includes application/json
encoded payload with message explaining
the error further.
POST /api/v1/mailer/subscribe
API endpoint calls REMP Mailer api endpoint and subscribes user to given mail type and variant.
Headers:
Example:
curl --location --request POST 'http://crm.press/api/v1/mailer/subscribe' \ --header 'Authorization: Bearer XXX' \ --form 'mail_type_code="alerts"' \ --form 'variant_code="daily"'
Response:
{ "status": "ok" }
POST /api/v1/mailer/unsubscribe
API endpoint calls REMP Mailer api endpoint and unsubscribes user to given mail type and variant.
Headers:
Example:
curl --location --request POST 'http://crm.press/api/v1/mailer/unsubscribe' \ --header 'Authorization: Bearer XXX' \ --form 'mail_type_code="alerts"' \ --form 'variant_code="daily"'
Response:
{ "status": "ok" }