# README
smtprelay
Simple Golang based SMTP relay/proxy server that accepts mail via SMTP and forwards it directly to another SMTP server.
Why another SMTP server?
Outgoing mails are usually send via SMTP to an MTA (Mail Transfer Agent) which is one of Postfix, Exim, Sendmail or OpenSMTPD on UNIX/Linux in most cases. You really don't want to setup and maintain any of those full blown kitchensinks yourself because they are complex, fragile and hard to configure.
My use case is simple. I need to send automatically generated mails from cron via msmtp/sSMTP/dma, mails from various services and network printers via a remote SMTP server without giving away my mail credentials to each device which produces mail.
Main features
- Simple configuration with ini file .env file or environment variables
- Supports SMTPS/TLS (465), STARTTLS (587) and unencrypted SMTP (25)
- Checks for sender, receiver, client IP
- Authentication support with file (LOGIN, PLAIN)
- Enforce encryption for authentication
- Forwards all mail to a smarthost (any SMTP server)
- Small codebase
- IPv6 support
# Functions
Dial returns a new Client connected to an SMTP server at addr.
IniParser is a parser for config files in classic key/value style format.
NewClient returns a new Client using an existing connection and host as a server name to be used when authenticating.
ParseRemote creates a remote from a given url in the following format:
smtp://[user[:password]@][netloc][:port][/remote_sender][?param1=value1&...] smtps://[user[:password]@][netloc][:port][/remote_sender][?param1=value1&...] starttls://[user[:password]@][netloc][:port][/remote_sender][?param1=value1&...]
Supported Params: - skipVerify: can be "true" or empty to prevent ssl verification of remote server's certificate.
SendMail connects to the server at addr with TLS when port 465 or smtps is specified or unencrypted otherwise and switches to TLS if possible, authenticates with the optional mechanism a if possible, and then sends an email from address from, to addresses to, with message msg.