Skip to content
/ meilo Public

A Go SMTP server for development/testing purposes.

License

Notifications You must be signed in to change notification settings

wawandco/meilo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Meilo

Meilo is an implementation of a test/development SMTP server written in Go. Meilo opens sent emails instead of sending them, this allows development workflows where ONLY the SMTP credentials are changed.

Prerequisites

  • Meilo requies Go 1.23 or later, you can download it from here

  • Meilo package:

go get github.com/wawandco/meilo

Usage

Create a new instance of Meilo

You have the ability to set the options for the SMTP server, these are totally optional, if you don't set them, Meilo will use the default values.

// Start the SMTP server
creds, err := meilo.Start(
	// Directory to put the files
	meilo.WithDir("/my/emails/folder"),
	// Port to use
	meilo.WithPort("1025"),
)
 
if err != nil {
	// Handle the error starting the server.
	...
}

This will start the SMTP server and return the credentials to be used in the email sending process.

Send an email using the SMTP server

//Then you can use the credentials to build the SMTP auth 
auth := smtp.PlainAuth("", creds.User, creds.Password, creds.Host),
from := "[email protected]"
to:= []string{"[email protected]"}
body:= []byte("Hello from meilo!")

// And then the creds instance has an Addr method to use when sending
err = smtp.SendMail(creds.Addr(), auth, from ,to, body)
if err != nil {
        // Handle the sending error
        ...

}

Options

meilo.WithDir(directory)

Allows to specify the directory where the emails will be stored, by default it will use the system's temporary directory.

meilo.WithPort(port):

Allows to specify the port of the SMTP server. This is useful when running multiple services in your development environment.

Roadmap / Ideas

  • Web interface
  • UI Improvements.
  • Deployable service for Staging/Testing.
  • Listing historically sent emails.