GithubHelp home page GithubHelp logo

smtpot's Introduction

SMTPot

SMTPot

A witch pot for your emails.


SMTPot is a simple SMTP server which accept emails and passes them to you handler.

Requirements

One of:

  • PHP 8.0+, ext-sockets, composer
  • Docker

Project setup

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).


Handlers

General information

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
}

Custom command

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 and connect

Without docker

Startup:

composer install
php server.php

Server will be available on port specified in config.php.

With docker

Startup:

docker compose build
docker compose up [-d]

Server will be available on port configured in SMTP_PORT ENV parameter (default is 2525)


Configuration reference

  • debug: Toggle logging to stdout.
  • port: Server port. Should be 25 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 of SMTPot\Handlers\HandlerInterface.

smtpot's People

Contributors

tyraelqp avatar zullkas avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.