Skip to content

BespokeTechLabs/ImprovMX-PHP-Client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ImprovMX API Client

This repo contains the source for a Laravel client library for the ImprovMX API.

Software License Packagist Downloads Latest Version

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 protected]", "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 protected]", "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 [email protected] to [email protected].
// Returns the newly created Alias entity or null (if failed to create).
$improvMx->client()->aliases()->add("domain.com", "user", "[email protected]");

// Return the Alias entity (or null) for a given alias e.g. ([email protected]).
$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", "[email protected]");

// 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 [email protected]. 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

About

ImprovMX API Client Library for Laravel PHP.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Languages