Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: Where's the documentation? (Simple Example included) #148

Open
coolaj86 opened this issue Jan 26, 2024 · 0 comments
Open

doc: Where's the documentation? (Simple Example included) #148

coolaj86 opened this issue Jan 26, 2024 · 0 comments

Comments

@coolaj86
Copy link

coolaj86 commented Jan 26, 2024

Since this doesn't have docs on godoc, or usage in the README, I'm just adding some here while I figure out how to use this.

  • Help
  • Config File / ENVs
  • Build
  • Bcrypt Passwords
  • Simple Example
smtprelay -config ~/.config/smtprelay/smtprelay.ini

Test with curl

This looks more complicated than it is because both styles of header need to be specified (in the message file and the mime headers). It may work with just the one in some curl versions. It also requires listening on port 465.

my_smtprelay_host=smtp.example.com
my_smtprelay_auth='my-user:my-pass'

my_from="[email protected]"
my_to="[email protected]"
my_subject='Hello, World!'
my_ts="$(date '+%F %H:%M:%S')"
my_text="It's ${my_ts}. Do you know where your emails are?"

my_file="$(mktemp)"
printf 'From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n%s\r\n' \
        "${my_from}" \
        "${my_to}" \
        "${my_subject}" \
        "${my_text}" \
        > "${my_file}"

# requires tls on 465
curl -v --url "smtps://${my_smtprelay_host}" \
  --ssl-reqd \
  --user "${my_smtprelay_auth}" \
  --mail-from "${my_from}" \
  --mail-rcpt "${my_to}" \
  --upload-file "${my_file}"

Help

Any unrecognized flag, such as --help, will show the help.

smtprelay --help
Usage of smtprelay:
  -allowed_nets string
    	Networks allowed to send mails (default "127.0.0.0/8 ::1/128")
  -allowed_recipients string
    	Regular expression for valid TO EMail addresses
  -allowed_sender string
    	Regular expression for valid FROM EMail addresses
  -allowed_users string
    	Path to file with valid users/passwords
  -command string
    	Path to pipe command
  -config string
    	Path to config file (ini format)
  -data_timeout string
    	Socket timeout for DATA command (default "5m")
  -hostname string
    	Server hostname (default "localhost.localdomain")
  -listen string
    	Address and port to listen for incoming SMTP (default "127.0.0.1:25 [::1]:25")
  -local_cert string
    	SSL certificate for STARTTLS/TLS
  -local_forcetls
    	Force STARTTLS (needs local_cert and local_key)
  -local_key string
    	SSL private key for STARTTLS/TLS
  -log_format string
    	Log output format (default "default")
  -log_level string
    	Minimum log level to output (default "info")
  -logfile string
    	Path to logfile
  -max_connections int
    	Max concurrent connections, use -1 to disable (default 100)
  -max_message_size int
    	Max message size in bytes (default 10240000)
  -max_recipients int
    	Max RCPT TO calls for each envelope (default 100)
  -read_timeout string
    	Socket timeout for read operations (default "60s")
  -remotes string
    	Outgoing SMTP servers
  -strict_sender
    	Use only SMTP servers with Sender matches to From
  -version
    	Show version information
  -welcome_msg string
    	Welcome message for SMTP session
  -write_timeout string
    	Socket timeout for write operations (default "60s")
error: error parsing commandline arguments: flag provided but not defined: -help

Config File / ENVs

This is the example config file:
https://github.com/decke/smtprelay/blob/master/smtprelay.ini

It can be converted to a the more webdev-friendly ENV format simply by using SMTPRELAY_* with the config options in upper case.

Build

git clone 

pushd ./

go build -o ./smtprelay ./

Bcrypt Passwords

There's a bcrypt hasher in ./cmd/hasher.go

Simple Example

Moved to #149

@coolaj86 coolaj86 changed the title doc: Where's the documentation? doc: Where's the documentation? (Simple Example included) Jan 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant