1. Go to this page and download the library: Download zone-eu/wildduck-php-client 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/ */
zone-eu / wildduck-php-client example snippets
use Zone\Wildduck\WildduckClient;
use Zone\Wildduck\Dto\User\CreateUserDto;
// Initialize client
$client = new WildduckClient([
'accessToken' => 'your-api-token',
'apiUrl' => 'https://api.wildduck.email',
]);
// Create a user
$createDto = new CreateUserDto(
username: 'john.doe',
password: 'SecurePass123!',
address: '[email protected]',
name: 'John Doe'
);
$result = $client->users()->create($createDto);
echo "User created with ID: {$result->id}\n";
// Get user details
$user = $client->users()->get($result->id);
echo "Username: {$user->username}\n";
echo "Email: {$user->address}\n";
// Update user
$updateDto = new UpdateUserDto(
name: 'John Updated Doe'
);
$client->users()->update($result->id, $updateDto);
// Delete user
$client->users()->delete($result->id);
use Zone\Wildduck\Dto\Filter\CreateFilterDto;
use Zone\Wildduck\Dto\Shared\FilterQueryDto;
use Zone\Wildduck\Dto\Shared\FilterActionDto;
$createDto = new CreateFilterDto(
name: 'Spam Filter',
query: new FilterQueryDto(from: '[email protected]'),
action: new FilterActionDto(delete: true)
);
$client->filters()->create($userId, $createDto);
// Stream user mailbox updates
$response = $client->events()->forUser($userId);
// Returns StreamedResponse that can be processed with EventSource
// Request DTOs
use Zone\Wildduck\Dto\User\CreateUserDto;
use Zone\Wildduck\Dto\User\UpdateUserDto;
// Response DTOs
use Zone\Wildduck\Dto\User\UserDto;
use Zone\Wildduck\Dto\User\UserInfoDto;
use Zone\Wildduck\Dto\PaginatedResultDto;
class UserService extends AbstractService
{
public function create(CreateUserDto|null $params = null): UserInfoDto
{
return $this->requestDto('post', '/users', $params, UserInfoDto::class);
}
public function get(string $id): UserDto
{
return $this->requestDto('get', "/users/{$id}", null, UserDto::class);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.