A witch pot for your emails.
SMTPot is a simple SMTP server which accept emails and passes them to you handler.
One of:
- PHP 8.0+, ext-sockets, composer
- Docker
git clone https://github.com/Tyraelqp/smtpot.git
cd smtpot
cp config.example.php config.php
cp .env.example .env
Now you can change default configuration for your needs (WARNING! Do not change port
if you want to use docker).
You can set your email handler in config.php
(Check Configuration reference section).
Handler should implement SMTPot\Handlers\HandlerInterface
interface.
You can use SMTPot\Handlers\AbstractHandler
class as base class for your handler.
Server will pass email message data as first argument to your handler's handleMessage
method. Email data scheme:
{
"from": string,
"to": Array<int, string>,
"headers": Array<string, string[]>,
"body": string
}
Also, you can create custom commands inside your handler.
These commands can be executed by opening new telnet session and sending HNDL some_command with args
command to server.
some_command with args
will be passed to your handler's handleCommand
method as first argument.
See HandlerExample for example.
Startup:
composer install
php server.php
Server will be available on port specified in config.php
.
Startup:
docker compose build
docker compose up [-d]
Server will be available on port configured in SMTP_PORT
ENV parameter (default is 2525
)
debug
: Toggle logging to stdout.port
: Server port. Should be25
if you want to use docker.read_timeout
: Timeout for reading data from socket. Socket will be closed if timeout exceeded.handler_filename
: Absolute path to php file with handler. File should return instance ofSMTPot\Handlers\HandlerInterface
.