Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fakesmtpd

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fakesmtpd

  • 0.3.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

fakesmtpd

Build Status

A fake SMTP server with a minimal HTTP API. Inspired by mailtrap.

Installation

fakesmtpd may be installed either as a Ruby gem or by directly downloading the server file which may then be used as an executable, e.g.:

gem install fakesmtpd

OR

curl -o fakesmtpd https://raw.github.com/modcloth-labs/fakesmtpd/master/lib/fakesmtpd/server.rb
chmod +x fakesmtpd

Usage

fakesmtpd is usable either as an executable or from within a Ruby process. The following examples are roughly equivalent.

# example command line invocation:
fakesmtpd 9025 ./fakesmtpd-messages -p ./fakesmtpd.pid -l ./fakesmtpd.log
# example in-process Ruby invocation:
require 'fakesmtpd'
FakeSMTPd::Server.main(
  %w(9025 ./fakesmtpd-messages -p ./fakesmtpd.pid -l ./fakesmtpd.log)
)

The FakeSMTPd::Runner class is intended to provide a formalized way to spawn and manage a separate Ruby process running FakeSMTPd::Server. This example is also equivalent to those provided above:

require 'fakesmtpd'

fakesmtpd = FakeSMTPd::Runner.new(
  dir: File.expand_path('../fakesmtpd-messages', __FILE__),
  port: 9025,
  logfile: File.expand_path('../fakesmtpd.log', __FILE__),
  pidfile: File.expand_path('../fakesmtpd.pid', __FILE__)
)
# This spawns another Ruby process via `RbConfig.ruby`
fakesmtpd.start

# ... do other stuff ...

# This will kill the previously-spawned process
fakesmtpd.stop

Once FakeSMTPd::Server.main has been invoked via one of the above methods, there will be both an SMTP and HTTP server running in a single Ruby process. The HTTP port is one more than the SMTP port specified.

HTTP API Usage

The HTTP API provides an index of all sent messages, the ability to fetch sent message content, and the ability to clear sent messages via the following:

GET /

Contains almost nothing but a link to /messages.

GET /messages

Contains an index of all sent messages, their IDs, their absolute filenames, and links to the content for each.

GET /messages/[[:digit:]]

Returns the content of the message with the given ID.

DELETE /messages

Clears all files out of the sent messages directory.

FAQs

Package last updated on 05 Sep 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc