smtprelay

package module
v0.0.0-...-9f3c16b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 4, 2022 License: GPL-3.0 Imports: 13 Imported by: 0

README

SMTP Relay

SMTP Relay is a very simple SMTP server that will relay all incoming emails to a remote mail service.
I use as a single entrypoint to relay all mails from my Docker containers to Mailgun.

Build Status Go Report Card Docker Image Size (latest by date)

Usage (Docker)

Docker-compose

The easiest way to run SMTP Relay is with docker-compose. Edit the .env file with your settings, download the docker-compose.yml file and run it with:

docker-compose up -d
Docker run

If you don't want to use Docker compose, you can always run the command manually:

docker run -it\
    -e REMOTE_SMTP_HOST=${REMOTE_SMTP_HOST} \
    -e REMOTE_SMTP_PORT=${REMOTE_SMTP_PORT} \
    -e REMOTE_SMTP_DISABLE_TLS=${REMOTE_SMTP_DISABLE_TLS} \
    -e REMOTE_SMTP_USER=${REMOTE_SMTP_USER} \
    -e REMOTE_SMTP_PASSWORD=${REMOTE_SMTP_PASSWORD} \
    -p 25:25 \
    denbeke/smtprelay

Usage (binary)

Download the latest SMTP Relay from the releases page.

Configure your settings in the .env and run the SMTP Relay with:

./smtprelay

Development

Run it manually with Go (requires Go 1.15 or newer):

go run cmd/smtprelay/*.go

To test the email functionality, you can send the test.txt SMTP mail with a tool like netcat:

nc localhost 25 -i 1 < mail.txt

Acknowledgments

Author

Mathias Beke

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	MetricsAddress string
	AccessLog      bool
	HandleAsync    bool
	SentryDSN      string

	// SMTP server config for SMTP Relay
	SMTP struct {
		Host string
		Port int
	}

	// Remote SMTP to which emails will be relayed
	RemoteSMTP struct {
		Host       string
		Port       int
		User       string
		Password   string
		DisableTLS bool
	}
}

Config contains all the config for serving SMTP Relay

func BuildConfigFromEnv

func BuildConfigFromEnv() *Config

BuildConfigFromEnv populates a config from env variables

func (*Config) Validate

func (config *Config) Validate() error

Validate validates whether all config is set and valid

type SMTPRelay

type SMTPRelay struct {
	// contains filtered or unexported fields
}

SMTPRelay holds the config.

func New

func New(config *Config) (*SMTPRelay, error)

New creates a new SMTP Relay with the given config

func (*SMTPRelay) Handle

func (r *SMTPRelay) Handle(s *smtp.State) error

Handle implements the GoPistolet SMTP Handler interface

func (*SMTPRelay) Serve

func (r *SMTPRelay) Serve()

Serve runs the actual SMTP server and handles all the mails

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL