Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://4commerce-technologies-ag.github.io/midi-smtp-server/
The highly customizable ruby SMTP-Server and SMTP-Service library with builtin support for AUTH and SSL/STARTTLS, 8BITMIME and SMTPUTF8, IPv4 and IPv6 and additional features.
https://4commerce-technologies-ag.github.io/midi-smtp-server/
automation fake-mail mail message-routing mock-mail mock-server mta openssl receive-messages ruby smtp smtp-server smtp-services starttls
Last synced: 11 days ago
JSON representation
The highly customizable ruby SMTP-Server and SMTP-Service library with builtin support for AUTH and SSL/STARTTLS, 8BITMIME and SMTPUTF8, IPv4 and IPv6 and additional features.
- Host: GitHub
- URL: https://4commerce-technologies-ag.github.io/midi-smtp-server/
- Owner: 4commerce-technologies-AG
- License: mit
- Created: 2014-07-07T23:08:14.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2023-11-20T03:40:17.000Z (12 months ago)
- Last Synced: 2024-10-27T05:43:41.422Z (15 days ago)
- Topics: automation, fake-mail, mail, message-routing, mock-mail, mock-server, mta, openssl, receive-messages, ruby, smtp, smtp-server, smtp-services, starttls
- Language: SCSS
- Homepage: https://4commerce-technologies-ag.github.io/midi-smtp-server/
- Size: 2.73 MB
- Stars: 75
- Watchers: 7
- Forks: 15
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: MIT-LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
- awesome-ruby - MidiSmtpServer - The highly customizable ruby SMTP-Service library with builtin support for AUTH and SSL/STARTTLS, 8BITMIME and SMTPUTF8, IPv4 and IPv6 and more. (Email)
README
MidiSmtpServer
The highly customizable ruby SMTP-Service library
-- Mail-Server, SMTP-Service, MTA, Email-Gateway & Router, Mail-Automation --
## MidiSmtpServer
MidiSmtpServer is the highly customizable ruby SMTP-Server and SMTP-Service library with builtin support for AUTH and SSL/STARTTLS, 8BITMIME and SMTPUTF8, IPv4 and IPv6 and additional features.
As a library it is mainly designed to be integrated into your projects as serving a SMTP-Server service. The lib will do nothing with your mail and you have to create your own event functions to handle and operate on incoming mails. We are using this in conjunction with [Mikel Lindsaar](https://github.com/mikel) great Mail component (https://github.com/mikel/mail). Time to run your own SMTP-Server service.
Checkout all the features and improvements (3.1.1 Process parallelization, 3.0.1 Logging enhancement, 2.3.x Multiple ports and addresses, 2.2.x Encryption [StartTLS], 2.1.0 Authentication [AUTH], 2.1.1 significant speed improvement, etc.) and get more details from section [changes and updates](https://github.com/4commerce-technologies-AG/midi-smtp-server#changes-and-updates).
MidiSmtpServer is an extremely flexible library and almost any aspect of SMTP communications can be handled by deriving its events and using its configuration options.
## Using the library
To derive your own SMTP-Server service with DATA processing simply do:
```ruby
# Server class
class MySmtpd < MidiSmtpServer::Smtpd# get each message after DATA .
def on_message_data_event(ctx)
# Output for debug
logger.debug("[#{ctx[:envelope][:from]}] for recipient(s): [#{ctx[:envelope][:to]}]...")# Just decode message once to make sure, that this message ist readable
mail = Mail.read_from_string(ctx[:message][:data])# handle incoming mail, just show the message subject
logger.debug(mail.subject)
endend
```Please checkout the source codes from [Examples](https://github.com/4commerce-technologies-AG/midi-smtp-server/tree/master/examples) for working SMTP-Services.
## Operation purposes
There is an endless field of application for SMTP services. You want to create your own SMTP Server as a mail gateway to clean up routed emails from spam and virus content. Incoming mails may be processed and handled native and by proper functions. A SMTP daemon can receive messages and forward them to a service like Slack, Trello, Redmine, Twitter, Facebook, Instagram and others.
This source code shows the example to receive messages via SMTP and store them to RabbitMQ (Message-Queue-Server) for subsequent processings etc.:
```ruby
# get each message after DATA .
def on_message_data_event(ctx)
# Just decode message once to make sure, that this message ist readable
mail = Mail.read_from_string(ctx[:message])# Publish to rabbit
@bunny_exchange.publish(mail.to_s, :headers => { 'x-smtp' => mail.header.to_s }, :routing_key => "to_queue")
end
```
## Installation
MidiSmtpServer is packaged as a RubyGem and hosted on rubygems.
#### CLI
You can easily install the package by entering following at your command line:
`gem install midi-smtp-server`
Use the component in your project sources by:
`require 'midi-smtp-server'`
#### Gemfile
When a `Gemfile` handles your dependencies, please consider to use the [pessimistic operator](https://thoughtbot.com/blog/rubys-pessimistic-operator) at least:
`gem 'midi-smtp-server', '~> 3.1.2''`
All changes by PATCH versions are always functional and compatible with no issues on update!
## Library documentation
Read the [MidiSmtpServer Documentation](https://midi-smtp-server.readthedocs.io/) for a complete library documentation.
## Reliable code
Since version 2.3 implementation and integration tests by minitest framework are added to this repository. While the implementation tests are mostly checking the components, the integration tests try to verify the correct exchange of messages for different scenarios. Last but not least the stress tests do catch some rare conditions to make sure that no information is leaving its thread and process. In addition all sources are checked by rubocop to ensure they fit to the style guides.
You may run all rubocop tests through the `rake` helper:
```bash
bundle exec rake rubocop
```You may also run all tests through the `rake` helper:
```bash
bundle exec rake test:all
```or with more verbose output:
```bash
bundle exec rake test:all v=1
```To just run just a part of the tests, you may select the `specs`, `unit`, `integration` or `stress` tests:
```bash
bundle exec rake test:specs
```To just run some selected (by regular expression) tests, you may use the `T=filter` option. The example will run only the tests and specs containing the word _connections_ in their method_name or describe_text:
```bash
bundle exec rake test:all v=1 T=connections
```_Be aware that the parameters and filter are case sensitive._
#### Style guide links
1. [Ruby style guide](https://rubystyle.guide)
2. [Minitest style guide](https://minitest.rubystyle.guide)
3. [Rubocop/Cop documentation](https://docs.rubocop.org)
4. [Rubocop/Minitest](https://docs.rubocop.org/rubocop-minitest/)
## Changes and updates
We suggest everybody using MidiSmtpServer to switch at least to latest 2.3.y. or best to 3.x. The update is painless and mostly without any source code changes :sunglasses:
For upgrades from previous versions or outdated _MiniSmtpServer_ gem you may follow the guides (see appendix) how to change your existing code to be compatible with the latest releases.
#### Latest release: 3.2.1 (2023-08-15)
1. New feature [proxy](https://midi-smtp-server.readthedocs.io/feature_proxy) ([check issue 49](https://github.com/4commerce-technologies-AG/midi-smtp-server/issues/49))
2. mkdocs update for readthedocs#### Changelog history
A complete list of updates and features can be read in the [CHANGELOG](https://github.com/4commerce-technologies-AG/midi-smtp-server/blob/master/CHANGELOG.md).
## Upgrading from previous releases :small_red_triangle:
Checkout the [Appendix Upgrade](https://midi-smtp-server.readthedocs.io/appendix_upgrade/) to get your code ready for the latest releases and read about any incompatibilities.
## Gem Package
You may find, use and download the gem package on [RubyGems.org](http://rubygems.org/gems/midi-smtp-server).
[![Gem Version](https://badge.fury.io/rb/midi-smtp-server.svg)](http://badge.fury.io/rb/midi-smtp-server)
[![Ruby](https://github.com/4commerce-technologies-AG/midi-smtp-server/actions/workflows/push-and-pr-testing-ruby-ci.yml/badge.svg)](https://github.com/4commerce-technologies-AG/midi-smtp-server/actions/workflows/push-and-pr-testing-ruby-ci.yml)
## Documentation
**[Project homepage](https://4commerce-technologies-ag.github.io/midi-smtp-server)** - you will find a micro-site at [Github](https://4commerce-technologies-ag.github.io/midi-smtp-server)
**[Class documentation](http://www.rubydoc.info/gems/midi-smtp-server/MidiSmtpServer/Smtpd)** - you will find a detailed description at [RubyDoc](http://www.rubydoc.info/gems/midi-smtp-server/MidiSmtpServer/Smtpd)
**[Library manual](https://midi-smtp-server.readthedocs.io/)** - you will find a manual at [ReadTheDocs](https://midi-smtp-server.readthedocs.io/)
## Author & Credits
Author: [Tom Freudenberg](http://about.me/tom.freudenberg)
[MidiSmtpServer Class](https://github.com/4commerce-technologies-AG/midi-smtp-server/) is inspired from [MiniSmtpServer Class](https://github.com/aarongough/mini-smtp-server) and code written by [Aaron Gough](https://github.com/aarongough) and [Peter Cooper](https://github.com/4commerce-technologies-AG/midi-smtp-server#author--credits)
Copyright (c) 2014-2023 [Tom Freudenberg](https://github.com/TomFreudenberg), [4commerce technologies AG](https://www.4commerce.de/), released under the MIT license