wiesner/forwardmx-api

Composer repository for the ForwardMX API

1.1.2 2023-04-17 09:58 UTC

This package is auto-updated.

Last update: 2024-04-07 16:16:25 UTC


README

Composer repository for the ForwardMX API.

Getting started

Firstly, you need to install this library with Composer:

composer require wiesner/forwardmx-api

Usage Example

To use ForwardMX, you need to construct a ForwardMX class with Api Key as a constructor parameter.

<?php

use ForwardMX\Exception\ForwardMxException;
use ForwardMX\ForwardMX;
use ForwardMX\ValueObject\Domain;

/**
* @return Domain[]
* @throws ForwardMxException
*/
function getAllDomains(): array
{
    $api = new ForwardMX('api-key');
    
    return $api->getDomains();
}

?>

List of All possible methods

To get any information from ForwardMx use these methods:

MethodReturn
getDomains()Array of Domain object
getDomainsByStatus(string $status)Array of Domain object
getDomain(string $domain)Domain object (throws exception if domain is not found)
getAliases(string $domain)Array of Alias object
getAllAliases()Array of DomainAlias object
getAliasesByDestination(string $domain, string $destination)Array of Alias object
getAllAliasesByDestination(string $destination)Array of DomainAliases object
getAlias(string $domain, string $alias)Alias object (throws exception if alias is not found)

To add/change something use these methods:

MethodReturn
createDomain(string $domain)void
createAlias(string $domain, string $alias, string $destination)void
createAliasForAllDomains(string $alias, string $destination)void
updateAlias(string $domain, string $alias, string $destination)void

To remove something use these methods:

MethodReturn
removeDomain(string $domain)void
removeAlias(string $domain, string $alias)void
removeAliasForAllDomains(string $alias)void

Notes:

  • string $domain parameter must be in a format "some.domain.com".
  • string $alias parameter must be in a format "some_alias" without "@" at the end of string!
  • string $destination parameter must be a standard email address like something@something.com.

List of All possible returned objects

some methods return these objects or array of objects.

ForwardMX\ValueObject\Alias

MethodReturn
getSource()string of source (alias with '@')
getDestination()string of destination email address
getCount()integer of count

ForwardMX\ValueObject\Domain

MethodReturn
getDomain()string of domain (like "something.com")
getStatus()string of domain status (like "active")

ForwardMX\ValueObject\DomainAliases

MethodReturn
getDomain()Domain object (see above)
getAliases()Array of Alias object (see above)

License

This PHP ForwardMx Api SDK is open source software licensed under the MIT license. See the LICENSE file for more info.

Epilogue

Special thanks to my wife Patricia <3. Thanks for Your support!