1. Go to this page and download the library: Download exbil/mailcow-php-api library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
exbil / mailcow-php-api example snippets
xbil\MailCowAPI;
// Create API client with default settings
$client = new MailCowAPI('https://mailcow.example.com', 'YOUR_API_KEY');
// Perform requests
$domains = $client->domains()->getDomains();
var_dump($domains);
// Set custom timeout (in seconds)
$client = new MailCowAPI(
'https://mailcow.example.com',
'YOUR_API_KEY',
null, // HTTP client
true, // Verify SSL
60 // 60 seconds timeout
);
use GuzzleHttp\Client;
$httpClient = new Client([
'timeout' => 30,
'proxy' => 'http://proxy.example.com:8080',
// ... other Guzzle options
]);
$client = new MailCowAPI(
'https://mailcow.example.com',
'YOUR_API_KEY',
$httpClient
);
// Recommended: Use environment variables
$client = new MailCowAPI(
getenv('MAILCOW_URL'),
getenv('MAILCOW_API_KEY'),
null,
getenv('APP_ENV') === 'production' // Only verify SSL in production
);