Download the PHP package horstoeko/zugferdmail without Composer
On this page you can find all versions of the php package horstoeko/zugferdmail. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download horstoeko/zugferdmail
More information about horstoeko/zugferdmail
Files in horstoeko/zugferdmail
Package zugferdmail
Short Description A library
License MIT
Homepage https://github.com/horstoeko/zugferdmail
Informations about the package zugferdmail
IMAP/POP3-Watcher for E-Documents
Table of Contents
- IMAP/POP3-Watcher for E-Documents
- Table of Contents
- Note
- License
- Overview
- Dependencies
- Installation
- Usage
- Configuration
- Check mail accounts for matching mails:
- Predefined handlers
- Implement your own handler
- A small example
- Console
- Start monitoring a mailbox
Note
[!CAUTION] This library is currently still considered experimental and should therefore be used with caution. I would be happy for an issue to be posted if bugs are found.
License
The code in this project is provided under the MIT license.
Overview
With this library it is possible to monitor mail accounts (IMAP and POP3) and to check and process incoming electronic invoice documents (ZUGFeRD PDF and XML).
Dependencies
This package makes use of
Installation
There is one recommended way to install horstoeko/zugferdmail
via Composer:
Usage
For detailed eplanation you may have a look in the examples of this package and the documentation attached to every release.
First, it is necessary to configure the library so that it is aware of the mail accounts to be checked. For IMAP accounts, the folders to be monitored must also be defined. In addition, any actions (handlers) can be defined for each mail account.
Configuration
First you need to create a configuration instance:
The mail accounts to be monitored must then be defined. You can also specify the folders and mimetypes to be checked:
Last but not least, the actions (handlers) to be performed are specified for each mail account, which are executed when a ZUGFeRD or XML document is found. Some of these handlers are already available, but you can also define your own actions:
You can also define callbacks to call when a document was found. If such a callback function returns the value false, then all remaining callback functions are not called:
Please note that the callbacks are neither loaded from a configuration file nor saved in one.
Check mail accounts for matching mails:
To perform the actual handling of all mail accounts, instantiate the class , to which the configuration is passed. The monitoring is started by calling the method
Predefined handlers
Class | Description |
---|---|
ZugferdMailHandlerNull | Does not perform any operations |
ZugferdMailHandlerCli | Displays brief information about the e-invoice document found on the console |
ZugferdMailHandlerCopyMessage | Copies the message to another (different) directory |
ZugferdMailHandlerMoveMessage | Moves the message to another (different) directory |
ZugferdMailHandlerDeleteMessage | Deletes the message |
ZugferdMailHandlerMarkSeenMessage | Marks the message as seen |
ZugferdMailHandlerMarkUnseenMessage | Marks the message as unseen |
ZugferdMailHandlerSaveToFile | Saves the E-Document to a specified directory, optionally with a different filename |
Implement your own handler
It is quite easy to implement your own action (handler). To do this, define your own class which extends a class from . This abstract class defines a single method , which is passed information about the folder, message, attachment and the e-invoice document:
An example:
The parameter $recognitionType is one of the constants from
Name | Vakue | Description |
---|---|---|
ZFMAIL_RECOGNITION_TYPE_PDF_CII | 0 | The document was recognized from a ZUGFeRD/Factur-X PDF attachment |
ZFMAIL_RECOGNITION_TYPE_XML_CII | 1 | The document was recognized from a ZUGFeRD/Factur-X XML attachment |
ZFMAIL_RECOGNITION_TYPE_XML_UBL | 2 | The document was recognized from a ZUGFeRD/Factur-X XML attachment (in UBL-Syntax) |
A small example
A possible implementation could look like this, for example:
Console
This library also includes a console application with which it is possible to carry out corresponding operations via shell. To get an overview of the existing commands from the “zfmail” namespace, use:
Start monitoring a mailbox
The command zfmail:processmailboxfolders
is available for monitoring a mailbox via shell:
This has the following parameters:
Parameter | Description | Default | Multiple |
---|---|---|---|
host | The IP or hostname | :x: | |
port | The port on the host | 993 | :x: |
protocol | The protocol to use | imap | :x: |
encryption | The encryption method to use | ssl | :x: |
validateCert | If given the SSL certificates will be validated | false | :x: |
username | The username to use for login | :x: | |
password | The password to use for login | :x: | |
authentication | The authentication method to use | :x: | |
timeout | The connection timeout | 30 | :x: |
folder | A folder to look into | :heavy_check_mark: | |
mimetype | An attachment mimetype to check | :heavy_check_mark: | |
handler | A handler to use | :heavy_check_mark: | |
enableublsupport | If given the application will check for UBL syntax too | false | :x: |
enablesymfonyvalidation | If given the application will validate the XML using symfony validator against the yaml definitions | false | :x: |
enablexsdvalidation | If given the application will validate the XML against the XSD definitions | false | :x: |
enablekositvalidation | If given the application will validate the XML using the KosIT validator (JAVA required) | false | :x: |
enableunseenonly | If given only unseen message are processed | false | :x: |
Example usage
All versions of zugferdmail with dependencies
horstoeko/mimedb Version ^1
horstoeko/stringmanagement Version ^1.0
horstoeko/zugferd Version ^1
horstoeko/zugferdublbridge Version ^1
swaggest/json-schema Version ^0.12.42
symfony/console Version ^5|^6|^7
symfony/mime Version ^5|^6|^7
vlucas/phpdotenv Version ^5
webklex/php-imap Version ^4|^5