Giter Club home page Giter Club logo

fake-smtp-server's Introduction

Simulating Email with a Fake SMTP Server Using Docker

fake-smtp-server build Docker pulls

Introduction

In the realm of software testing, having a reliable environment to simulate email interactions is crucial. Docker, a powerful containerization technology, offers a seamless solution for creating and managing isolated environments. This tutorial will guide you through setting up a fake SMTP server using a Docker image, allowing you to mimic email exchanges for testing purposes.

Prerequisites

Step 1: Obtain the Docker Image

Pull the "FakeSMTP" Docker image, a popular choice for emulating SMTP interactions:

docker pull haravich/fake-smtp-server

Step 2: Run the Fake SMTP Server

Launch the fake SMTP server container, exposing ports 1025 and 1080:

docker run -d -p 1025:1025 -p 1080:1080 haravich/fake-smtp-server

Step 3: Access the Web Interface

Open your web browser and navigate to http://localhost:1080 to access the fake SMTP server's web interface. Here, you can monitor incoming email traffic.

Step 4: Send Test Emails

Configure your application's SMTP settings to use the IP address of the machine running the Docker container, and set port 1025 for the SMTP server. Test emails sent from your application will be captured by the fake SMTP server and displayed in the web interface.

Step 5: Analyze and Verify

Use the web interface to analyze email interactions and ensure that your application behaves as expected. This controlled testing environment prevents interference with real email systems.

Conclusion

Creating a fake SMTP server using Docker enhances your email-related testing capabilities. Docker's isolation and port mapping features enable realistic email simulation without affecting real email infrastructure. With the web interface, you can efficiently monitor and validate email interactions, streamlining your testing workflow and enhancing your software's reliability.

License

This project is licensed under the MIT LICENSE. See the LICENSE file for more details.

Source Repository

The source code for this project is available on GitHub.

Credits

MailCatcher

Catches mail and serves it through a dream.

MailCatcher runs a super simple SMTP server which catches any message sent to it to display in a web interface. Run mailcatcher, set your favourite app to deliver to smtp://127.0.0.1:1025 instead of your default SMTP server, then check out http://127.0.0.1:1080 to see the mail that's arrived so far.

The mailcatcher gem file used in this Dockerfile is created and maintained by Samuel Cochran. The source code can be found in Github.

The copy of LICENSE has been included in this repo as well. The original LICENSE can be found in Mailcatcher

fake-smtp-server's People

Contributors

haravich avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

fake-smtp-server's Issues

arm64 support

Platform: archlinux
kernel: Linux ******* 6.2.10-1-aarch64-ARCH #1 SMP PREEMPT_DYNAMIC Fri Apr 7 10:32:52 MDT 2023 aarch64 GNU/Linux
docker: Docker version 24.0.7, build afdd53b4e3

Pulling 0/1
⠦ mailcatcher Pulling 1.7s
no matching manifest for linux/arm64/v8 in the manifest list entries

cannot load such file -- sqlite3/sqlite3_native

Running with

docker run -d -p 1025:1025 -p 1080:1080 haravich/fake-smtp-server

Throws this error

Starting MailCatcher v0.9.0
<internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:86:in `require': cannot load such file -- sqlite3/sqlite3_native (LoadError)
	from <internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:86:in `require'
	from /usr/local/bundle/gems/sqlite3-1.7.1-x86_64-linux/lib/sqlite3.rb:6:in `rescue in <top (required)>'
	from /usr/local/bundle/gems/sqlite3-1.7.1-x86_64-linux/lib/sqlite3.rb:2:in `<top (required)>'
	from <internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:86:in `require'
	from <internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:86:in `require'
	from /usr/local/bundle/gems/mailcatcher-0.9.0/lib/mail_catcher/mail.rb:6:in `<top (required)>'
	from <internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:86:in `require'
	from <internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:86:in `require'
	from /usr/local/bundle/gems/mailcatcher-0.9.0/lib/mail_catcher/smtp.rb:5:in `<top (required)>'
	from <internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:86:in `require'
	from <internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:86:in `require'
	from /usr/local/bundle/gems/mailcatcher-0.9.0/lib/mail_catcher.rb:183:in `block (2 levels) in run!'
	from /usr/local/bundle/gems/mailcatcher-0.9.0/lib/mail_catcher.rb:239:in `rescue_port'
	from /usr/local/bundle/gems/mailcatcher-0.9.0/lib/mail_catcher.rb:182:in `block in run!'
	from /usr/local/bundle/gems/eventmachine-1.0.9.1/lib/eventmachine.rb:193:in `run_machine'
	from /usr/local/bundle/gems/eventmachine-1.0.9.1/lib/eventmachine.rb:193:in `run'
	from /usr/local/bundle/gems/mailcatcher-0.9.0/lib/mail_catcher.rb:180:in `run!'
	from /usr/local/bundle/gems/mailcatcher-0.9.0/bin/mailcatcher:6:in `<top (required)>'
	from /usr/local/bundle/bin/mailcatcher:25:in `load'
	from /usr/local/bundle/bin/mailcatcher:25:in `<main>'
<internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:86:in `require': Error relocating /usr/local/bundle/gems/sqlite3-1.7.1-x86_64-linux/lib/sqlite3/3.2/sqlite3_native.so: posix_fallocate64: symbol not found - /usr/local/bundle/gems/sqlite3-1.7.1-x86_64-linux/lib/sqlite3/3.2/sqlite3_native.so (LoadError)
	from <internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:86:in `require'
	from /usr/local/bundle/gems/sqlite3-1.7.1-x86_64-linux/lib/sqlite3.rb:4:in `<top (required)>'
	from <internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:86:in `require'
	from <internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:86:in `require'
	from /usr/local/bundle/gems/mailcatcher-0.9.0/lib/mail_catcher/mail.rb:6:in `<top (required)>'
	from <internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:86:in `require'
	from <internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:86:in `require'
	from /usr/local/bundle/gems/mailcatcher-0.9.0/lib/mail_catcher/smtp.rb:5:in `<top (required)>'
	from <internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:86:in `require'
	from <internal:/usr/local/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:86:in `require'
	from /usr/local/bundle/gems/mailcatcher-0.9.0/lib/mail_catcher.rb:183:in `block (2 levels) in run!'
	from /usr/local/bundle/gems/mailcatcher-0.9.0/lib/mail_catcher.rb:239:in `rescue_port'
	from /usr/local/bundle/gems/mailcatcher-0.9.0/lib/mail_catcher.rb:182:in `block in run!'
	from /usr/local/bundle/gems/eventmachine-1.0.9.1/lib/eventmachine.rb:193:in `run_machine'
	from /usr/local/bundle/gems/eventmachine-1.0.9.1/lib/eventmachine.rb:193:in `run'
	from /usr/local/bundle/gems/mailcatcher-0.9.0/lib/mail_catcher.rb:180:in `run!'
	from /usr/local/bundle/gems/mailcatcher-0.9.0/bin/mailcatcher:6:in `<top (required)>'
	from /usr/local/bundle/bin/mailcatcher:25:in `load'
	from /usr/local/bundle/bin/mailcatcher:25:in `<main>'

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.