bespoke / improvmx
ImprovMX API client library for Laravel PHP
Fund package maintenance!
BespokeTechLabs
Installs: 1 432
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 1
Forks: 1
Open Issues: 1
Requires
- illuminate/support: ~7|~8
Requires (Dev)
- orchestra/testbench: ~5|~6
- phpunit/phpunit: ~9.0
This package is auto-updated.
Last update: 2024-10-29 06:18:51 UTC
README
This repo contains the source for a Laravel client library for the ImprovMX API.
Check out the change log, releases, license, code of conduct, and contribution guidelines.
Installation
This version supports PHP 7.2-8.0. To get started, simply require the project into an existing Laravel application using Composer.
composer require bespoke/improvmx
Follow these installation instructions if you do not already have composer
installed.
The project has a service provider which is automatically configured in new versions of Laravel.
To get the project working, simply add your ImprovMX API key into your .env file.
IMPROVMX_KEY=XXXXXXXXXXXXXX
Getting Started
The recommended method for using the ImprovMX client is to access it using the Laravel service provider.
This will construct your client automatically using the API key within your .env file.
$improvMx = new ImprovMx(); $client = $improvMx->client();
Alternatively, an ImprovMX client can be constructed manually.
$client = new Bespoke\ImprovMX\Client("INPUT_API_KEY_MANUALLY");
Once the client has been constructed, the API can be consumed as follows:
$client->account()->getAccountDetails(); $client->domains()->list();
Example Usage
Account
$improvMx = new ImprovMX(); // Return the Account entity. $accountDetails = $improvMx->client()->account()->getAccountDetails(); // Return a collection of white-labelled domains. $domains = $improvMx->client()->account()->getWhiteLabeledDomains();
Domains
$improvMx = new ImprovMX(); // Return a collection of Domain entities. $domains = $improvMx->client()->domains()->list(); // Returns the newly created Domain entity or null (if failed to create). $improvMx->client()->domains()->add("domain.com", "email@email.com", "whitelabel-domain.com"); // Return the Domain entity (or null). $domain = $improvMx->client()->domains()->get("test.com"); // Update the details for a domain - returns the Domain entity or null. $improvMx->client()->domains()->update("domain.com", "email@email.com", "whitelabel-domain.com"); // Returns delete successful - true or false. $success = $improvMx->client()->domains()->delete("domain.com"); // Returns a RecordValidity entity. $details = $improvMx->client()->domains()->checkDomainValidity("domain.com");
Aliases
$improvMx = new ImprovMX(); // Return a collection of Alias entities for a domain. $aliases = $improvMx->client()->aliases()->list("domain.com"); // This command sets up email forwarding from user@domain.com to forward@email.com. // Returns the newly created Alias entity or null (if failed to create). $improvMx->client()->aliases()->add("domain.com", "user", "forward@email.com"); // Return the Alias entity (or null) for a given alias e.g. (alias@domain.com). $alias = $improvMx->client()->aliases()->get("domain.com", "alias"); // Update the forwarding address for an alias - returns the Alias entity or null. $improvMx->client()->aliases()->update("domain.com", "alias", "forward@email.com"); // Returns delete successful - true or false. $success = $improvMx->client()->aliases()->delete("domain.com", "alias");
Logs
$improvMx = new ImprovMX(); // Return a collection of Log entities for a domain. $logs = $improvMx->client()->logs()->getDomainLogs("domain.com"); // Return a collection of Log entities for a domain's alias. $logs = $improvMx->client()->logs()->getAliasLogs("domain.com", "alias");
SMTP Credentials
$improvMx = new ImprovMX(); // Return a collection of Credential entities for a domain. $credentials = $improvMx->client()->smtpCredentials()->list("domain.com"); // Add a new SMTP account for a domain (returns with the Credential entity or null). $logs = $improvMx->client()->smtpCredentials()->add("domain.com", "username", "password"); // Update the password for an SMTP account (by username) - returns the Credential entity or null. $improvMx->client()->smtpCredentials()->update("domain.com", "username", "newPassword"); // Returns delete successful - true or false. $success = $improvMx->client()->smtpCredentials()->delete("domain.com", "username");
Security
If you discover a security vulnerability within this package, please send an email to Bespoke Technology Labs at hello@bespoke.dev. All security vulnerabilities will be promptly addressed. You may view our full security policy here.
License
The ImprovMX API Client Library is licensed under The MIT License (MIT).
Credits
- Lewis Smallwood - Bespoke Technology Labs