PHPackages                             richardhj/epost-api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. richardhj/epost-api

AbandonedArchivedLibrary[API Development](/categories/api)

richardhj/epost-api
===================

E-POSTBUSINESS API PHP integration

v0.9.0(9y ago)97.9k6[2 PRs](https://github.com/richardhj/epost-api/pulls)2PHPPHP ^5.4 || ^7.0

Since Oct 5Pushed 8y ago1 watchersCompare

[ Source](https://github.com/richardhj/epost-api)[ Packagist](https://packagist.org/packages/richardhj/epost-api)[ RSS](/packages/richardhj-epost-api/feed)WikiDiscussions feature/v0.10.0 Synced yesterday

READMEChangelog (2)Dependencies (2)Versions (5)Used By (2)

E-POSTBUSINESS API PHP integration
==================================

[](#e-postbusiness-api-php-integration)

[![Build Status](https://camo.githubusercontent.com/e6b0402003eaff94b49c5123ddd999877366bddde79ead63049ee791917144d4/68747470733a2f2f7472617669732d63692e6f72672f72696368617264686a2f65706f73742d6170692e7376673f6272616e63683d6d61737465723f7374796c653d666c61742d737175617265)](https://travis-ci.org/richardhj/epost-api)[![Latest Version on Packagist](https://camo.githubusercontent.com/faff8dc6928cf96b3f64cc9cea152601ac15ac8f9c76d5bf5d56a417d03faad7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f72696368617264686a2f65706f73742d6170692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/richardhj/epost-api)![Software License](https://camo.githubusercontent.com/2bc95db9d4d6b319fe40fe1a46431a18f9684b30d516775115c5d0df6aa3e9b4/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4c47504c2d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)[![Dependency Status](https://camo.githubusercontent.com/605fdb24f29853acca1c70bb6c167cc07f54d1dca7ecd717ee788a2b741de1e6/68747470733a2f2f7777772e76657273696f6e6579652e636f6d2f7068702f72696368617264686a3a65706f73742d6170692f62616467652e7376673f7374796c653d666c61742d737175617265)](https://www.versioneye.com/php/richardhj:epost-api)

This package provides an PHP integration of the E-POSTBUSINESS API.

Install
-------

[](#install)

Via Composer

```
$ composer require richardhj/epost-api
```

Usage
-----

[](#usage)

### Authenticate user

[](#authenticate-user)

First of all you have to fetch an `AccessToken` instance by authenticating the user. I recommend to use this [OAuth2 Provider](https://github.com/richardhj/oauth2-epost) for fetching the access token.

```
// Authenticate
/** @var League\OAuth2\Client\Token\AccessToken $token */
$token = $this->fetchAccessToken();
```

### Provide metadata

[](#provide-metadata)

#### Envelope

[](#envelope)

We're going big steps forward and create a `Letter` instance. The `Letter` collects all metadata (envelope, delivery options…), creates a letter draft on the E-POST portal and finally sends the letter.

```
// Create letter and envelope
$letter = new Richardhj\EPost\Api\Letter();
$envelope = new Richardhj\EPost\Api\Metadata\Envelope();
$envelope
    ->setSystemMessageTypeNormal()  // For sending an electronic letter *OR*
    ->setSystemMessageTypeHybrid()  // For sending a physical letter
    ->setSubject('Example letter');
```

##### Recipients

[](#recipients)

We created our envelope and we need to add the recipients. This is how for an electronic letter.

```
// Add recipients for normal letter
$recipient = new Richardhj\EPost\Api\Metadata\Envelope\Recipient\Normal::createFromFriendlyEmail('John Doe ');

$envelope->addRecipientNormal($recipient);
```

And this is how for a printed letter. For printed letters, only one recipient is valid!

```
// Set recipients and delivery options for printed letter
$recipient = new Richardhj\EPost\Api\Metadata\Envelope\Recipient\Hybrid();
$recipient
    ->setFirstName('John')
    ->setLastName('Doe')
    ->setStreetName('…')
    ->setZipCode('1234')
    ->setCity('…');

$envelope->addRecipientPrinted($recipient);
```

#### Delivery options

[](#delivery-options)

We also define `DeliveryOptions` as they define whether the letter is going to be colored and so on. This is for printed letters only.

```
// Set delivery options
$deliveryOptions = new Richardhj\EPost\Api\Metadata\DeliveryOptions();
$deliveryOptions
    ->setRegisteredStandard()   // This will make the letter sent as "Einschreiben ohne Optionen"
    ->setColorColored()         // To make it expensive
    ->setCoverLetterIncluded(); // The cover letter (with recipient address block) is included in the attachments

$letter->setDeliveryOptions($deliveryOptions);
```

### Finishing

[](#finishing)

We're going to start the communication with the E-POST portal.

```
// Prepare letter
$letter
    ->setTestEnvironment(true)
    ->setAccessToken($token)
    ->setEnvelope($envelope)
    ->setCoverLetter('This is an example');

// Set attachments
$letter->addAttachment('/var/www/test.pdf');

// Create and send letter
try {
    $letter
        ->create()
        ->send();

} catch (GuzzleHttp\Exception\ClientException $e) {
    $errorInformation = \GuzzleHttp\json_decode($e->getResponse()->getBody());
}
```

### Fetch postage info

[](#fetch-postage-info)

If you wonder how expensive the letter is going to be.

Case 1: You already defined a letter with envelope and so on:

```
$priceInformation = $letter->queryPriceInformation();

var_dump($priceInformation);
```

Case 2: You need to provide `PostageInfo`:

```
$postageInfo = new Richardhj\EPost\Api\Metadata\PostageInfo();
$postageInfo
    ->setLetterTypeHybrid()
    ->setLetterSize(3)
    ->setDeliveryOptions($deliveryOptions);

$letter = new Richardhj\EPost\Api\Letter();
$letter->setPostageInfo($postageInfo);
$priceInformation = $letter->queryPriceInformation();

var_dump($priceInformation);
```

### Delete letters

[](#delete-letters)

If you already have a `Letter` instance, deleting is that easy:

```
$letter
    ->create() // Yeah, it must be created beforehand, so we have a "letterId"
    ->delete();
```

Otherwise you need to know the `letterId`.

```
$letter = new EPost\Api\Letter();
$letter
    ->setLetterId('asdf-124-asdf')
    ->delete();
```

`delete()` will delete the letter irrecoverably on the E-POST portal. You have to possibility to use `moveToTrash()`otherwise.

License
-------

[](#license)

The GNU Lesser General Public License (LGPL).

Contributing
------------

[](#contributing)

Please follow the [Symfony Coding Standards](http://symfony.com/doc/current/contributing/code/standards.html).

Beispiel-Konzept
----------------

[](#beispiel-konzept)

[Dieses Konzept](https://www.dropbox.com/s/fd7hl33galgy8jh/Konzept_Henkenjohann_E-POST-Contao.pdf?dl=0) erklärt die verschiedenen Komponenten, die im Rahmen einer E-POSTBUSINESS-Integration für das CMS Contao genutzt wurden.

[![Konzept](https://camo.githubusercontent.com/645248462bdcca1b8c9dd4fb6067fb2702af030b50ab9d9c76d34c443a1fef41/68747470733a2f2f7777772e64726f70626f782e636f6d2f732f72666f7575316269646b6736327a732f4b6f6e7a6570745f48656e6b656e6a6f68616e6e5f452d504f53542d436f6e74616f2d312e706e673f646c3d31)](https://www.dropbox.com/s/fd7hl33galgy8jh/Konzept_Henkenjohann_E-POST-Contao.pdf?dl=0)

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~451 days

Total

2

Last Release

3103d ago

PHP version history (2 changes)v0.9.0PHP ^5.4 || ^7.0

v0.10-beta.1PHP ^7.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1284725?v=4)[Richard Henkenjohann](/maintainers/richardhj)[@richardhj](https://github.com/richardhj)

---

Top Contributors

[![richardhj](https://avatars.githubusercontent.com/u/1284725?v=4)](https://github.com/richardhj "richardhj (16 commits)")

---

Tags

apiapi-wrapperdeutsche-postepostepostbusiness-api

### Embed Badge

![Health badge](/badges/richardhj-epost-api/health.svg)

```
[![Health](https://phpackages.com/badges/richardhj-epost-api/health.svg)](https://phpackages.com/packages/richardhj-epost-api)
```

###  Alternatives

[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3661.2M46](/packages/tencentcloud-tencentcloud-sdk-php)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k496.1k33](/packages/neuron-core-neuron-ai)[avalara/avataxclient

Client library for Avalara's AvaTax suite of business tax calculation and processing services. Uses the REST v2 API.

528.3M7](/packages/avalara-avataxclient)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

252.5k](/packages/eslazarev-wildberries-sdk)[files.com/files-php-sdk

Files.com PHP SDK

2478.1k](/packages/filescom-files-php-sdk)[aimeos/prisma

A powerful PHP package for integrating media related Large Language Models (LLMs) into your applications

1942.4k4](/packages/aimeos-prisma)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
