1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2026-07-31 16:19:50 +00:00

Merge branch 'feature/envconfig' into develop

This commit is contained in:
James Hillyerd
2018-03-25 17:05:52 -07:00
679 changed files with 424 additions and 821 deletions
+2 -3
View File
@@ -20,7 +20,7 @@ builds:
- amd64
goarm:
- "6"
main: .
main: ./cmd/inbucket
ldflags: -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}}
- binary: client
goos:
@@ -46,9 +46,8 @@ archive:
- LICENSE*
- README*
- CHANGELOG*
- inbucket.bat
- etc/**/*
- themes/**/*
- ui/**/*
fpm:
bindir: /usr/local/bin
snapshot:
+6
View File
@@ -18,6 +18,12 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Changed
- Massive refactor of back-end code. Inbucket should now be both easier and
more enjoyable to work on.
- Renamed `themes` directory to `ui` and eliminated the intermediate `bootstrap`
directory.
- Docker build:
- Uses the same default ports as other builds; smtp:2500 http:9000 pop3:1100
- Uses volume `/config` for `greeting.html`
- Uses volume `/storage` for mail storage
## [v1.3.1] - 2018-03-10
+18 -11
View File
@@ -2,23 +2,30 @@
# Inbucket website: http://www.inbucket.org/
FROM golang:1.10-alpine
MAINTAINER James Hillyerd, @jameshillyerd
# Configuration (WORKDIR doesn't support env vars)
# Configuration
ENV INBUCKET_SRC $GOPATH/src/github.com/jhillyerd/inbucket
ENV INBUCKET_HOME /opt/inbucket
WORKDIR $INBUCKET_HOME
ENTRYPOINT ["/con/context/start-inbucket.sh"]
CMD ["/con/configuration/inbucket.conf"]
ENV INBUCKET_SMTP_DOMAINNOSTORE bitbucket.local
ENV INBUCKET_SMTP_TIMEOUT 30s
ENV INBUCKET_POP3_TIMEOUT 30s
ENV INBUCKET_WEB_UIDIR $INBUCKET_HOME/ui
ENV INBUCKET_WEB_GREETINGFILE /config/greeting.html
ENV INBUCKET_WEB_COOKIEAUTHKEY secret-inbucket-session-cookie-key
ENV INBUCKET_STORAGE_TYPE file
ENV INBUCKET_STORAGE_PARAMS path:/storage
ENV INBUCKET_STORAGE_RETENTIONPERIOD 72h
ENV INBUCKET_STORAGE_MAILBOXMSGCAP 300
# Ports: SMTP, HTTP, POP3
EXPOSE 10025 10080 10110
EXPOSE 2500 9000 1100
# Persistent Volumes, following convention at:
# https://github.com/docker/docker/issues/9277
# NOTE /con/context is also used, not exposed by default
VOLUME /con/configuration
VOLUME /con/data
# Persistent Volumes
VOLUME /config
VOLUME /storage
WORKDIR $INBUCKET_HOME
ENTRYPOINT "/start-inbucket.sh"
# Build Inbucket
COPY . $INBUCKET_SRC/
+349
View File
@@ -0,0 +1,349 @@
# Inbucket Configuration
Inbucket is configured via environment variables. Most options have a
reasonable default, but it is likely you will need to change some to suite your
desired use cases.
Running `inbucket -help` will yield a condensed summary of the environment
variables it supports:
KEY DEFAULT DESCRIPTION
INBUCKET_LOGLEVEL INFO TRACE, INFO, WARN, or ERROR
INBUCKET_SMTP_ADDR 0.0.0.0:2500 SMTP server IP4 host:port
INBUCKET_SMTP_DOMAIN inbucket HELO domain
INBUCKET_SMTP_DOMAINNOSTORE Load testing domain
INBUCKET_SMTP_MAXRECIPIENTS 200 Maximum RCPT TO per message
INBUCKET_SMTP_MAXMESSAGEBYTES 10240000 Maximum message size
INBUCKET_SMTP_STOREMESSAGES true Store incoming mail?
INBUCKET_SMTP_TIMEOUT 300s Idle network timeout
INBUCKET_POP3_ADDR 0.0.0.0:1100 POP3 server IP4 host:port
INBUCKET_POP3_DOMAIN inbucket HELLO domain
INBUCKET_POP3_TIMEOUT 600s Idle network timeout
INBUCKET_WEB_ADDR 0.0.0.0:9000 Web server IP4 host:port
INBUCKET_WEB_UIDIR ui User interface dir
INBUCKET_WEB_GREETINGFILE ui/greeting.html Home page greeting HTML
INBUCKET_WEB_TEMPLATECACHE true Cache templates after first use?
INBUCKET_WEB_MAILBOXPROMPT @inbucket Prompt next to mailbox input
INBUCKET_WEB_COOKIEAUTHKEY Session cipher key (text)
INBUCKET_WEB_MONITORVISIBLE true Show monitor tab in UI?
INBUCKET_WEB_MONITORHISTORY 30 Monitor remembered messages
INBUCKET_STORAGE_TYPE memory Storage impl: file or memory
INBUCKET_STORAGE_PARAMS Storage impl parameters, see docs.
INBUCKET_STORAGE_RETENTIONPERIOD 24h Duration to retain messages
INBUCKET_STORAGE_RETENTIONSLEEP 50ms Duration to sleep between mailboxes
INBUCKET_STORAGE_MAILBOXMSGCAP 500 Maximum messages per mailbox
The following documentation will describe each of these in more detail.
## Global
### Log Level
`INBUCKET_LOGLEVEL`
This setting controls the verbosity of log output. A small desktop installation
should probably select INFO, but a busy shared installation would be better off
with WARN or ERROR.
- Default: `INFO`
- Values: one of `TRACE`, `INFO`, `WARN`, or `ERROR`
## SMTP
### Address and Port
`INBUCKET_SMTP_ADDR`
The IPv4 address and TCP port number the SMTP server should listen on, separated
by a colon. Some operating systems may prevent Inbucket from listening on port
25 without escalated privileges. Using an IP address of 0.0.0.0 will cause
Inbucket to listen on all available network interfaces.
- Default: `0.0.0.0:2500`
### Greeting Domain
`INBUCKET_SMTP_DOMAIN`
The domain used in the SMTP greeting:
220 domain Inbucket SMTP ready
Most SMTP clients appear to ignore this value.
- Default: `inbucket`
### Load Testing/No Store Domain
`INBUCKET_SMTP_DOMAINNOSTORE`
Mail sent to this domain will not be stored by Inbucket. This is helpful if you
are load or soak testing a service, and do not plan to inspect the resulting
emails. Messages sent to a domain other than this will be stored normally.
- Default: None
- Example: `bitbucket.local`
### Maximum Recipients
`INBUCKET_SMTP_MAXRECIPIENTS`
Maximum number of recipients allowed (SMTP `RCPT TO` phase). If you are testing
a mailing list server, you may need to increase this value. For comparison, the
Postfix SMTP server uses a default of 1000, it would be unwise to exceed this.
- Default: `200`
### Maximum Message Size
`INBUCKET_SMTP_MAXMESSAGEBYTES`
Maximum allowable size of a message (including headers) in bytes. Messages
exceeding this size will be rejected during the SMTP `DATA` phase.
- Default: `10240000` (10MB)
### Store Messages
`INBUCKET_SMTP_STOREMESSAGES`
This option can be used to disable mail storage entirely. Useful for load
testing, or turning Inbucket into a black hole that will consume our entire
solar system.
- Default: `true`
- Values: `true` or `false`
### Network Idle Timeout
`INBUCKET_SMTP_TIMEOUT`
Delay before closing an idle SMTP connection. The SMTP RFC recommends 300
seconds. Consider reducing this *significantly* if you plan to expose Inbucket
to the public internet.
- Default: `300s`
- Values: Duration ending in `s` for seconds, `m` for minutes
## POP3
### Address and Port
`INBUCKET_POP3_ADDR`
The IPv4 address and TCP port number the POP3 server should listen on, separated
by a colon. Some operating systems may prevent Inbucket from listening on port
110 without escalated privileges. Using an IP address of 0.0.0.0 will cause
Inbucket to listen on all available network interfaces.
- Default: `0.0.0.0:1100`
### Greeting Domain
`INBUCKET_POP3_DOMAIN`
The domain used in the POP3 greeting:
+OK Inbucket POP3 server ready <26641.1522000423@domain>
Most POP3 clients appear to ignore this value.
- Default: `inbucket`
### Network Idle Timeout
`INBUCKET_POP3_TIMEOUT`
Delay before closing an idle POP3 connection. The POP3 RFC recommends 600
seconds. Consider reducing this *significantly* if you plan to expose Inbucket
to the public internet.
- Default: `600s`
- Values: Duration ending in `s` for seconds, `m` for minutes
## Web
### Address and Port
`INBUCKET_WEB_ADDR`
The IPv4 address and TCP port number the HTTP server should listen on, separated
by a colon. Some operating systems may prevent Inbucket from listening on port
80 without escalated privileges. Using an IP address of 0.0.0.0 will cause
Inbucket to listen on all available network interfaces.
- Default: `0.0.0.0:9000`
### UI Directory
`INBUCKET_WEB_UIDIR`
This directory contains the templates and static assets for the web user
interface. You will need to change this if the current working directory
doesn't contain the `ui` directory at startup.
Inbucket will load templates from the `templates` sub-directory, and serve
static assets from the `static` sub-directory.
- Default: `ui`
- Values: Operating system specific path syntax
### Greeting HTML File
`INBUCKET_WEB_GREETINGFILE`
The content of the greeting file will be injected into the front page of
Inbucket. It can be used to instruct users on how to send mail into your
Inbucket installation, as well as link to REST documentation, etc.
- Default: `ui/greeting.html`
### Template Caching
`INBUCKET_WEB_TEMPLATECACHE`
Tells Inbucket to cache parsed template files. This should be left as default
unless you are a developer working on the Inbucket web interface.
- Default: `true`
- Values: `true` or `false`
### Mailbox Prompt
`INBUCKET_WEB_MAILBOXPROMPT`
Text prompt displayed to the right of the mailbox name input field in the web
interface. Can be used to nudge your users into typing just the mailbox name
instead of an entire email address.
Set to an empty string to hide the prompt.
- Default: `@inbucket`
### Cookie Authentication Key
`INBUCKET_WEB_COOKIEAUTHKEY`
Inbucket stores session information in an encrypted browser cookie. Unless
specified, Inbucket generates a random key at startup. The only notable data
stored in a user session is the list of recently accessed mailboxes.
- Default: None
- Value: Text string, no particular format required
### Monitor Visible
`INBUCKET_WEB_MONITORVISIBLE`
If true, the Monitor tab will be available, allowing users to observe all
messages received by Inbucket as they arrive. Disabling the monitor facilitates
security through obscurity.
This setting has no impact on the availability of the underlying WebSocket,
which may be used by other parts of the Inbucket interface or continuous
integration tests.
- Default: `true`
- Values: `true` or `false`
### Monitor History
`INBUCKET_WEB_MONITORHISTORY`
The number of messages to remember on the *server* for new Monitor clients.
Does not impact the amount of *new* messages displayed by the Monitor.
Increasing this has no appreciable impact on memory use, but may slow down the
Monitor user interface.
This setting has the same effect on the amount of messages available via
WebSocket.
Setting to 0 will disable the monitor, but will probably break new mail
notifications in the web interface when I finally get around to implementing
them.
- Default: `30`
- Values: Integer greater than or equal to 0
## Storage
### Type
`INBUCKET_STORAGE_TYPE`
Selects the storage implementation to use. Currently Inbucket supports two:
- `file`: stores messages as individual files in a nested directory structure
based on the hash of the mailbox name. Each mailbox also includes an index
file to speed up enumeration of the mailbox contents.
- `memory`: stores messages in RAM, they will be lost if Inbucket is restarted,
or crashes, etc.
File storage is recommended for larger/shared installations. Memory is better
suited to desktop or continuous integration test use cases.
- Default: `memory`
- Values: `file` or `memory`
### Parameters
`INBUCKET_STORAGE_PARAMS`
Parameters specific to the storage type selected. Formatted as a comma
separated list of key:value pairs.
- Default: None
- Examples: `maxkb=10240` or `path=/tmp/inbucket`
#### file parameters
- `path`: Operating system specific path to the directory where mail should be
stored.
#### memory parameters
- `maxkb`: Maximum size of the mail store in kilobytes. The oldest messages in
the store will be deleted to enforce the limit. In-memory storage has some
overhead, for now it is recommended to set this to half the total amount of
memory you are willing to allocate to Inbucket.
### Retention Period
`INBUCKET_STORAGE_RETENTIONPERIOD`
If set, Inbucket will scan the contents of its mail store once per minute,
removing messages older than this. This will be enforced regardless of the type
of storage configured.
- Default: `24h`
- Values: Duration ending in `m` for minutes, `h` for hours. Should be
significantly longer than one minute, or `0` to disable.
### Retention Sleep
`INBUCKET_STORAGE_RETENTIONSLEEP`
Duration to sleep between scanning each mailbox for expired messages.
Increasing this number will reduce disk thrashing, but extend the length of time
required to complete a scan of the entire mail store.
This delay is still enforced for memory stores, but could be reduced from the
default. Setting to `0` may degrade performance of HTTP/SMTP/POP3 services.
- Default: `50ms`
- Values: Duration ending in `ms` for milliseconds, `s` for seconds
### Per Mailbox Message Cap
`INBUCKET_STORAGE_MAILBOXMSGCAP`
Maximum messages allowed in a single mailbox, exceeding this will cause older
messages to be deleted from the mailbox.
- Default: `500`
- Values: Positive integer, or `0` to disable
+19
View File
@@ -0,0 +1,19 @@
#!/bin/sh
# dev-start.sh
# description: Developer friendly Inbucket configuration
export INBUCKET_LOGLEVEL="TRACE"
export INBUCKET_SMTP_DOMAINNOSTORE="bitbucket.local"
export INBUCKET_WEB_TEMPLATECACHE="false"
export INBUCKET_WEB_COOKIEAUTHKEY="not-secret"
export INBUCKET_STORAGE_TYPE="file"
export INBUCKET_STORAGE_PARAMS="path:/tmp/inbucket"
export INBUCKET_STORAGE_RETENTIONPERIOD="5m"
if ! test -x ./inbucket; then
echo "$PWD/inbucket not found/executable!" >&2
echo "Run this script from the inbucket root directory after running make" >&2
exit 1
fi
exec ./inbucket $*
-129
View File
@@ -1,129 +0,0 @@
# devel.conf
# Sample development configuration
#############################################################################
[DEFAULT]
# Not used directly, but is typically referenced below in %()s format.
install.dir=.
default.domain=inbucket.local
#############################################################################
[logging]
# Options from least to most verbose: ERROR, WARN, INFO, TRACE
level=TRACE
#############################################################################
[smtp]
# IPv4 address to listen for SMTP connections on.
ip4.address=0.0.0.0
# IPv4 port to listen for SMTP connections on.
ip4.port=2500
# used in SMTP greeting
domain=%(default.domain)s
# optional: mail sent to accounts at this domain will not be stored,
# for mixed use (content and load testing)
domain.nostore=bitbucket.local
# Maximum number of RCPT TO: addresses we allow from clients, the SMTP
# RFC recommends this be at least 100.
max.recipients=100
# How long we allow a network connection to be idle before hanging up on the
# client, SMTP RFC recommends at least 5 minutes (300 seconds).
max.idle.seconds=30
# Maximum allowable size of message body in bytes (including attachments)
max.message.bytes=20480000
# Should we place messages into the datastore, or just throw them away
# (for load testing): true or false
store.messages=true
#############################################################################
[pop3]
# IPv4 address to listen for POP3 connections on.
ip4.address=0.0.0.0
# IPv4 port to listen for POP3 connections on.
ip4.port=1100
# used in POP3 greeting
domain=%(default.domain)s
# How long we allow a network connection to be idle before hanging up on the
# client, POP3 RFC requires at least 10 minutes (600 seconds).
max.idle.seconds=600
#############################################################################
[web]
# IPv4 address to serve HTTP web interface on
ip4.address=0.0.0.0
# IPv4 port to serve HTTP web interface on
ip4.port=9000
# Name of web theme to use
theme=bootstrap
# Prompt displayed between the mailbox entry field and View button. Leave
# empty or comment out to hide the prompt.
mailbox.prompt=@inbucket
# Path to the selected themes template files
template.dir=%(install.dir)s/themes/%(theme)s/templates
# Should we cache parsed templates (set to false during theme dev)
template.cache=false
# Path to the selected themes public (static) files
public.dir=%(install.dir)s/themes/%(theme)s/public
# Path to the greeting HTML displayed on front page, can be moved out of
# installation dir for customization
greeting.file=%(install.dir)s/themes/greeting.html
# Key used to sign session cookie data so that it cannot be tampered with.
# If this is left unset, Inbucket will generate a random key at startup
# and previous sessions will be invalidated.
cookie.auth.key=secret-inbucket-session-cookie-key
# Enable or disable the live message monitor tab for the web UI. This will let
# anybody see all messages delivered to Inbucket. This setting has no impact
# on the availability of the underlying WebSocket.
monitor.visible=true
# How many historical message headers should be cached for display by new
# monitor connections. It does not limit the number of messages displayed by
# the browser once the monitor is open; all freshly received messages will be
# appended to the on screen list. This setting also affects the underlying
# API/WebSocket.
monitor.history=30
#############################################################################
[datastore]
# Path to the datastore, mail will be written into subdirectories
path=/tmp/inbucket
# How many minutes after receipt should a message be stored until it's
# automatically purged. To retain messages until manually deleted, set this
# to 0
retention.minutes=0
# How many milliseconds to sleep after purging messages from a mailbox.
# This should help reduce disk I/O when there are a large number of messages
# to purge.
retention.sleep.millis=100
# Maximum number of messages we will store in a single mailbox. If this
# number is exceeded, the oldest message in the box will be deleted each
# time a new message is received for it.
mailbox.message.cap=100
-131
View File
@@ -1,131 +0,0 @@
# inbucket.conf
# Configuration for Inbucket inside of Docker
#
# These should be reasonable defaults for a production install of Inbucket
#############################################################################
[DEFAULT]
# Not used directly, but is typically referenced below in %()s format.
install.dir=/opt/inbucket
default.domain=inbucket.local
#############################################################################
[logging]
# Options from least to most verbose: ERROR, WARN, INFO, TRACE
level=INFO
#############################################################################
[smtp]
# IPv4 address to listen for SMTP connections on.
ip4.address=0.0.0.0
# IPv4 port to listen for SMTP connections on.
ip4.port=10025
# used in SMTP greeting
domain=%(default.domain)s
# optional: mail sent to accounts at this domain will not be stored,
# for mixed use (content and load testing)
domain.nostore=bitbucket.local
# Maximum number of RCPT TO: addresses we allow from clients, the SMTP
# RFC recommends this be at least 100.
max.recipients=100
# How long we allow a network connection to be idle before hanging up on the
# client, SMTP RFC recommends at least 5 minutes (300 seconds).
max.idle.seconds=300
# Maximum allowable size of message body in bytes (including attachments)
max.message.bytes=2048000
# Should we place messages into the datastore, or just throw them away
# (for load testing): true or false
store.messages=true
#############################################################################
[pop3]
# IPv4 address to listen for POP3 connections on.
ip4.address=0.0.0.0
# IPv4 port to listen for POP3 connections on.
ip4.port=10110
# used in POP3 greeting
domain=%(default.domain)s
# How long we allow a network connection to be idle before hanging up on the
# client, POP3 RFC requires at least 10 minutes (600 seconds).
max.idle.seconds=600
#############################################################################
[web]
# IPv4 address to serve HTTP web interface on
ip4.address=0.0.0.0
# IPv4 port to serve HTTP web interface on
ip4.port=10080
# Name of web theme to use
theme=bootstrap
# Prompt displayed between the mailbox entry field and View button. Leave
# empty or comment out to hide the prompt.
mailbox.prompt=@inbucket
# Path to the selected themes template files
template.dir=%(install.dir)s/themes/%(theme)s/templates
# Should we cache parsed templates (set to false during theme dev)
template.cache=true
# Path to the selected themes public (static) files
public.dir=%(install.dir)s/themes/%(theme)s/public
# Path to the greeting HTML displayed on front page, can be moved out of
# installation dir for customization
greeting.file=/con/configuration/greeting.html
# Key used to sign session cookie data so that it cannot be tampered with.
# If this is left unset, Inbucket will generate a random key at startup
# and previous sessions will be invalidated.
#cookie.auth.key=secret-inbucket-session-cookie-key
# Enable or disable the live message monitor tab for the web UI. This will let
# anybody see all messages delivered to Inbucket. This setting has no impact
# on the availability of the underlying WebSocket.
monitor.visible=true
# How many historical message headers should be cached for display by new
# monitor connections. It does not limit the number of messages displayed by
# the browser once the monitor is open; all freshly received messages will be
# appended to the on screen list. This setting also affects the underlying
# API/WebSocket.
monitor.history=30
#############################################################################
[datastore]
# Path to the datastore, mail will be written into subdirectories
path=/con/data
# How many minutes after receipt should a message be stored until it's
# automatically purged. To retain messages until manually deleted, set this
# to 0
retention.minutes=4320
# How many milliseconds to sleep after purging messages from a mailbox.
# This should help reduce disk I/O when there are a large number of messages
# to purge.
retention.sleep.millis=100
# Maximum number of messages we will store in a single mailbox. If this
# number is exceeded, the oldest message in the box will be deleted each
# time a new message is received for it.
mailbox.message.cap=300
+1 -2
View File
@@ -3,7 +3,7 @@
# description: start inbucket (runs within a docker container)
CONF_SOURCE="$INBUCKET_HOME/defaults"
CONF_TARGET="/con/configuration"
CONF_TARGET="/config"
set -eo pipefail
@@ -18,7 +18,6 @@ install_default_config() {
fi
}
install_default_config "inbucket.conf"
install_default_config "greeting.html"
exec "$INBUCKET_HOME/bin/inbucket" $*
+2 -3
View File
@@ -35,10 +35,9 @@ set -x
mkdir -p "$bindir"
install inbucket "$bindir"
mkdir -p "$contextdir"
install etc/docker/defaults/start-inbucket.sh "$contextdir"
cp -r themes "$installdir/"
install etc/docker/defaults/start-inbucket.sh /
cp -r ui "$installdir/"
mkdir -p "$defaultsdir"
cp etc/docker/defaults/inbucket.conf "$defaultsdir"
cp etc/docker/defaults/greeting.html "$defaultsdir"
set +x
-131
View File
@@ -1,131 +0,0 @@
# inbucket.conf
# homebrew inbucket configuration
# {{}} values will be replaced during installation
#############################################################################
[DEFAULT]
# Not used directly, but is typically referenced below in %()s format.
default.domain=inbucket.local
themes.dir={{HOMEBREW_PREFIX}}/share/inbucket/themes
datastore.dir={{HOMEBREW_PREFIX}}/var/inbucket/datastore
#############################################################################
[logging]
# Options from least to most verbose: ERROR, WARN, INFO, TRACE
level=INFO
#############################################################################
[smtp]
# IPv4 address to listen for SMTP connections on.
ip4.address=0.0.0.0
# IPv4 port to listen for SMTP connections on.
ip4.port=2500
# used in SMTP greeting
domain=%(default.domain)s
# optional: mail sent to accounts at this domain will not be stored,
# for mixed use (content and load testing)
domain.nostore=bitbucket.local
# Maximum number of RCPT TO: addresses we allow from clients, the SMTP
# RFC recommends this be at least 100.
max.recipients=100
# How long we allow a network connection to be idle before hanging up on the
# client, SMTP RFC recommends at least 5 minutes (300 seconds).
max.idle.seconds=300
# Maximum allowable size of message body in bytes (including attachments)
max.message.bytes=2048000
# Should we place messages into the datastore, or just throw them away
# (for load testing): true or false
store.messages=true
#############################################################################
[pop3]
# IPv4 address to listen for POP3 connections on.
ip4.address=0.0.0.0
# IPv4 port to listen for POP3 connections on.
ip4.port=1100
# used in POP3 greeting
domain=%(default.domain)s
# How long we allow a network connection to be idle before hanging up on the
# client, POP3 RFC requires at least 10 minutes (600 seconds).
max.idle.seconds=600
#############################################################################
[web]
# IPv4 address to serve HTTP web interface on
ip4.address=0.0.0.0
# IPv4 port to serve HTTP web interface on
ip4.port=9000
# Name of web theme to use
theme=bootstrap
# Prompt displayed between the mailbox entry field and View button. Leave
# empty or comment out to hide the prompt.
mailbox.prompt=@inbucket
# Path to the selected themes template files
template.dir=%(themes.dir)s/%(theme)s/templates
# Should we cache parsed templates (set to false during theme dev)
template.cache=true
# Path to the selected themes public (static) files
public.dir=%(themes.dir)s/%(theme)s/public
# Path to the greeting HTML displayed on front page, can be moved out of
# installation dir for customization
greeting.file=%(themes.dir)s/greeting.html
# Key used to sign session cookie data so that it cannot be tampered with.
# If this is left unset, Inbucket will generate a random key at startup
# and previous sessions will be invalidated.
cookie.auth.key=secret-inbucket-session-cookie-key
# Enable or disable the live message monitor tab for the web UI. This will let
# anybody see all messages delivered to Inbucket. This setting has no impact
# on the availability of the underlying WebSocket.
monitor.visible=true
# How many historical message headers should be cached for display by new
# monitor connections. It does not limit the number of messages displayed by
# the browser once the monitor is open; all freshly received messages will be
# appended to the on screen list. This setting also affects the underlying
# API/WebSocket.
monitor.history=30
#############################################################################
[datastore]
# Path to the datastore, mail will be written into subdirectories
path=%(datastore.dir)s
# How many minutes after receipt should a message be stored until it's
# automatically purged. To retain messages until manually deleted, set this
# to 0
retention.minutes=10080
# How many milliseconds to sleep after purging messages from a mailbox.
# This should help reduce disk I/O when there are a large number of messages
# to purge.
retention.sleep.millis=100
# Maximum number of messages we will store in a single mailbox. If this
# number is exceeded, the oldest message in the box will be deleted each
# time a new message is received for it.
mailbox.message.cap=100
-129
View File
@@ -1,129 +0,0 @@
# inbucket.conf
# Sample inbucket configuration
#############################################################################
[DEFAULT]
# Not used directly, but is typically referenced below in %()s format.
install.dir=.
default.domain=inbucket.local
#############################################################################
[logging]
# Options from least to most verbose: ERROR, WARN, INFO, TRACE
level=INFO
#############################################################################
[smtp]
# IPv4 address to listen for SMTP connections on.
ip4.address=0.0.0.0
# IPv4 port to listen for SMTP connections on.
ip4.port=2500
# used in SMTP greeting
domain=%(default.domain)s
# optional: mail sent to accounts at this domain will not be stored,
# for mixed use (content and load testing)
#domain.nostore=bitbucket.local
# Maximum number of RCPT TO: addresses we allow from clients, the SMTP
# RFC recommends this be at least 100.
max.recipients=100
# How long we allow a network connection to be idle before hanging up on the
# client, SMTP RFC recommends at least 5 minutes (300 seconds).
max.idle.seconds=300
# Maximum allowable size of message body in bytes (including attachments)
max.message.bytes=2048000
# Should we place messages into the datastore, or just throw them away
# (for load testing): true or false
store.messages=true
#############################################################################
[pop3]
# IPv4 address to listen for POP3 connections on.
ip4.address=0.0.0.0
# IPv4 port to listen for POP3 connections on.
ip4.port=1100
# used in POP3 greeting
domain=%(default.domain)s
# How long we allow a network connection to be idle before hanging up on the
# client, POP3 RFC requires at least 10 minutes (600 seconds).
max.idle.seconds=600
#############################################################################
[web]
# IPv4 address to serve HTTP web interface on
ip4.address=0.0.0.0
# IPv4 port to serve HTTP web interface on
ip4.port=9000
# Name of web theme to use
theme=bootstrap
# Prompt displayed between the mailbox entry field and View button. Leave
# empty or comment out to hide the prompt.
mailbox.prompt=@inbucket
# Path to the selected themes template files
template.dir=%(install.dir)s/themes/%(theme)s/templates
# Should we cache parsed templates (set to false during theme dev)
template.cache=true
# Path to the selected themes public (static) files
public.dir=%(install.dir)s/themes/%(theme)s/public
# Path to the greeting HTML displayed on front page, can be moved out of
# installation dir for customization
greeting.file=%(install.dir)s/themes/greeting.html
# Key used to sign session cookie data so that it cannot be tampered with.
# If this is left unset, Inbucket will generate a random key at startup
# and previous sessions will be invalidated.
#cookie.auth.key=secret-inbucket-session-cookie-key
# Enable or disable the live message monitor tab for the web UI. This will let
# anybody see all messages delivered to Inbucket. This setting has no impact
# on the availability of the underlying WebSocket.
monitor.visible=true
# How many historical message headers should be cached for display by new
# monitor connections. It does not limit the number of messages displayed by
# the browser once the monitor is open; all freshly received messages will be
# appended to the on screen list. This setting also affects the underlying
# API/WebSocket.
monitor.history=30
#############################################################################
[datastore]
# Path to the datastore, mail will be written into subdirectories
path=/tmp/inbucket
# How many minutes after receipt should a message be stored until it's
# automatically purged. To retain messages until manually deleted, set this
# to 0
retention.minutes=240
# How many milliseconds to sleep after purging messages from a mailbox.
# This should help reduce disk I/O when there are a large number of messages
# to purge.
retention.sleep.millis=100
# Maximum number of messages we will store in a single mailbox. If this
# number is exceeded, the oldest message in the box will be deleted each
# time a new message is received for it.
mailbox.message.cap=500
-129
View File
@@ -1,129 +0,0 @@
# inbucket.conf
# Sample inbucket configuration
#############################################################################
[DEFAULT]
# Not used directly, but is typically referenced below in %()s format.
install.dir=/opt/inbucket
default.domain=inbucket.local
#############################################################################
[logging]
# Options from least to most verbose: ERROR, WARN, INFO, TRACE
level=INFO
#############################################################################
[smtp]
# IPv4 address to listen for SMTP connections on.
ip4.address=0.0.0.0
# IPv4 port to listen for SMTP connections on.
ip4.port=25
# used in SMTP greeting
domain=%(default.domain)s
# optional: mail sent to accounts at this domain will not be stored,
# for mixed use (content and load testing)
#domain.nostore=bitbucket.local
# Maximum number of RCPT TO: addresses we allow from clients, the SMTP
# RFC recommends this be at least 100.
max.recipients=100
# How long we allow a network connection to be idle before hanging up on the
# client, SMTP RFC recommends at least 5 minutes (300 seconds).
max.idle.seconds=300
# Maximum allowable size of message body in bytes (including attachments)
max.message.bytes=2048000
# Should we place messages into the datastore, or just throw them away
# (for load testing): true or false
store.messages=true
#############################################################################
[pop3]
# IPv4 address to listen for POP3 connections on.
ip4.address=0.0.0.0
# IPv4 port to listen for POP3 connections on.
ip4.port=110
# used in POP3 greeting
domain=%(default.domain)s
# How long we allow a network connection to be idle before hanging up on the
# client, POP3 RFC requires at least 10 minutes (600 seconds).
max.idle.seconds=600
#############################################################################
[web]
# IPv4 address to serve HTTP web interface on
ip4.address=0.0.0.0
# IPv4 port to serve HTTP web interface on
ip4.port=80
# Name of web theme to use
theme=bootstrap
# Prompt displayed between the mailbox entry field and View button. Leave
# empty or comment out to hide the prompt.
mailbox.prompt=@inbucket
# Path to the selected themes template files
template.dir=%(install.dir)s/themes/%(theme)s/templates
# Should we cache parsed templates (set to false during theme dev)
template.cache=true
# Path to the selected themes public (static) files
public.dir=%(install.dir)s/themes/%(theme)s/public
# Path to the greeting HTML displayed on front page, can be moved out of
# installation dir for customization
greeting.file=%(install.dir)s/themes/greeting.html
# Key used to sign session cookie data so that it cannot be tampered with.
# If this is left unset, Inbucket will generate a random key at startup
# and previous sessions will be invalidated.
#cookie.auth.key=secret-inbucket-session-cookie-key
# Enable or disable the live message monitor tab for the web UI. This will let
# anybody see all messages delivered to Inbucket. This setting has no impact
# on the availability of the underlying WebSocket.
monitor.visible=true
# How many historical message headers should be cached for display by new
# monitor connections. It does not limit the number of messages displayed by
# the browser once the monitor is open; all freshly received messages will be
# appended to the on screen list. This setting also affects the underlying
# API/WebSocket.
monitor.history=30
#############################################################################
[datastore]
# Path to the datastore, mail will be written into subdirectories
path=/var/opt/inbucket
# How many minutes after receipt should a message be stored until it's
# automatically purged. To retain messages until manually deleted, set this
# to 0
retention.minutes=240
# How many milliseconds to sleep after purging messages from a mailbox.
# This should help reduce disk I/O when there are a large number of messages
# to purge.
retention.sleep.millis=100
# Maximum number of messages we will store in a single mailbox. If this
# number is exceeded, the oldest message in the box will be deleted each
# time a new message is received for it.
mailbox.message.cap=500
-129
View File
@@ -1,129 +0,0 @@
# win-sample.conf
# Sample inbucket configuration for Windows
#############################################################################
[DEFAULT]
# Not used directly, but is typically referenced below in %()s format.
install.dir=.
default.domain=inbucket.local
#############################################################################
[logging]
# Options from least to most verbose: ERROR, WARN, INFO, TRACE
level=INFO
#############################################################################
[smtp]
# IPv4 address to listen for SMTP connections on.
ip4.address=0.0.0.0
# IPv4 port to listen for SMTP connections on.
ip4.port=2500
# used in SMTP greeting
domain=%(default.domain)s
# optional: mail sent to accounts at this domain will not be stored,
# for mixed use (content and load testing)
#domain.nostore=bitbucket.local
# Maximum number of RCPT TO: addresses we allow from clients, the SMTP
# RFC recommends this be at least 100.
max.recipients=100
# How long we allow a network connection to be idle before hanging up on the
# client, SMTP RFC recommends at least 5 minutes (300 seconds).
max.idle.seconds=300
# Maximum allowable size of message body in bytes (including attachments)
max.message.bytes=2048000
# Should we place messages into the datastore, or just throw them away
# (for load testing): true or false
store.messages=true
#############################################################################
[pop3]
# IPv4 address to listen for POP3 connections on.
ip4.address=0.0.0.0
# IPv4 port to listen for POP3 connections on.
ip4.port=1100
# used in POP3 greeting
domain=%(default.domain)s
# How long we allow a network connection to be idle before hanging up on the
# client, POP3 RFC requires at least 10 minutes (600 seconds).
max.idle.seconds=600
#############################################################################
[web]
# IPv4 address to serve HTTP web interface on
ip4.address=0.0.0.0
# IPv4 port to serve HTTP web interface on
ip4.port=9000
# Name of web theme to use
theme=bootstrap
# Prompt displayed between the mailbox entry field and View button. Leave
# empty or comment out to hide the prompt.
mailbox.prompt=@inbucket
# Path to the selected themes template files
template.dir=%(install.dir)s\themes\%(theme)s\templates
# Should we cache parsed templates (set to false during theme dev)
template.cache=true
# Path to the selected themes public (static) files
public.dir=%(install.dir)s\themes\%(theme)s\public
# Path to the greeting HTML displayed on front page, can be moved out of
# installation dir for customization
greeting.file=%(install.dir)s\themes\greeting.html
# Key used to sign session cookie data so that it cannot be tampered with.
# If this is left unset, Inbucket will generate a random key at startup
# and previous sessions will be invalidated.
#cookie.auth.key=secret-inbucket-session-cookie-key
# Enable or disable the live message monitor tab for the web UI. This will let
# anybody see all messages delivered to Inbucket. This setting has no impact
# on the availability of the underlying WebSocket.
monitor.visible=true
# How many historical message headers should be cached for display by new
# monitor connections. It does not limit the number of messages displayed by
# the browser once the monitor is open; all freshly received messages will be
# appended to the on screen list. This setting also affects the underlying
# API/WebSocket.
monitor.history=30
#############################################################################
[datastore]
# Path to the datastore, mail will be written into subdirectories
path=.\inbucket-data
# How many minutes after receipt should a message be stored until it's
# automatically purged. To retain messages until manually deleted, set this
# to 0
retention.minutes=240
# How many milliseconds to sleep after purging messages from a mailbox.
# This should help reduce disk I/O when there are a large number of messages
# to purge.
retention.sleep.millis=100
# Maximum number of messages we will store in a single mailbox. If this
# number is exceeded, the oldest message in the box will be deleted each
# time a new message is received for it.
mailbox.message.cap=500
-1
View File
@@ -1 +0,0 @@
inbucket.exe etc\win-sample.conf
+3 -4
View File
@@ -42,7 +42,7 @@ type SMTP struct {
Domain string `required:"true" default:"inbucket" desc:"HELO domain"`
DomainNoStore string `desc:"Load testing domain"`
MaxRecipients int `required:"true" default:"200" desc:"Maximum RCPT TO per message"`
MaxMessageBytes int `required:"true" default:"2048000" desc:"Maximum message size"`
MaxMessageBytes int `required:"true" default:"10240000" desc:"Maximum message size"`
StoreMessages bool `required:"true" default:"true" desc:"Store incoming mail?"`
Timeout time.Duration `required:"true" default:"300s" desc:"Idle network timeout"`
}
@@ -57,10 +57,9 @@ type POP3 struct {
// Web contains the HTTP server configuration.
type Web struct {
Addr string `required:"true" default:"0.0.0.0:9000" desc:"Web server IP4 host:port"`
TemplateDir string `required:"true" default:"themes/bootstrap/templates" desc:"Theme template dir"`
UIDir string `required:"true" default:"ui" desc:"User interface dir"`
GreetingFile string `required:"true" default:"ui/greeting.html" desc:"Home page greeting HTML"`
TemplateCache bool `required:"true" default:"true" desc:"Cache templates after first use?"`
PublicDir string `required:"true" default:"themes/bootstrap/public" desc:"Theme public dir"`
GreetingFile string `required:"true" default:"themes/greeting.html" desc:"Home page greeting HTML"`
MailboxPrompt string `required:"true" default:"@inbucket" desc:"Prompt next to mailbox input"`
CookieAuthKey string `desc:"Session cipher key (text)"`
MonitorVisible bool `required:"true" default:"true" desc:"Show monitor tab in UI?"`
+6 -5
View File
@@ -3,8 +3,10 @@
package log
import (
"golang.org/x/sys/unix"
"log"
"os"
"golang.org/x/sys/unix"
)
// closeStdin will close stdin on Unix platforms - this is standard practice
@@ -12,20 +14,19 @@ import (
func closeStdin() {
if err := os.Stdin.Close(); err != nil {
// Not a fatal error
Errorf("Failed to close os.Stdin during log setup")
log.Printf("Failed to close os.Stdin during log setup")
}
}
// reassignStdout points stdout/stderr to our logfile on systems that support
// the Dup2 syscall per https://github.com/golang/go/issues/325
func reassignStdout() {
Tracef("Unix reassignStdout()")
if err := unix.Dup2(int(logf.Fd()), 1); err != nil {
// Not considered fatal
Errorf("Failed to re-assign stdout to logfile: %v", err)
log.Printf("Failed to re-assign stdout to logfile: %v", err)
}
if err := unix.Dup2(int(logf.Fd()), 2); err != nil {
// Not considered fatal
Errorf("Failed to re-assign stderr to logfile: %v", err)
log.Printf("Failed to re-assign stderr to logfile: %v", err)
}
}
+3 -3
View File
@@ -3,6 +3,7 @@
package log
import (
"log"
"os"
)
@@ -16,7 +17,6 @@ func closeStdin() {
// reassignStdout points stdout/stderr to our logfile on systems that do not
// support the Dup2 syscall
func reassignStdout() {
Tracef("Windows reassignStdout()")
if !stdOutsClosed {
// Close std* streams to prevent accidental output, they will be redirected to
// our logfile below
@@ -24,11 +24,11 @@ func reassignStdout() {
// Warning: this will hide panic() output, sorry Windows users
if err := os.Stderr.Close(); err != nil {
// Not considered fatal
Errorf("Failed to close os.Stderr during log setup")
log.Printf("Failed to close os.Stderr during log setup")
}
if err := os.Stdin.Close(); err != nil {
// Not considered fatal
Errorf("Failed to close os.Stdin during log setup")
log.Printf("Failed to close os.Stdin during log setup")
}
os.Stdout = logf
os.Stderr = logf
+1 -2
View File
@@ -36,8 +36,7 @@ func setupWebServer(mm message.Manager) *bytes.Buffer {
http.DefaultServeMux = http.NewServeMux()
cfg := &config.Root{
Web: config.Web{
TemplateDir: "../themes/bootstrap/templates",
PublicDir: "../themes/bootstrap/public",
UIDir: "../ui",
},
}
shutdownChan := make(chan bool)
+9 -3
View File
@@ -6,6 +6,7 @@ import (
"expvar"
"net"
"net/http"
"path/filepath"
"time"
"github.com/gorilla/mux"
@@ -20,6 +21,11 @@ import (
// Handler is a function type that handles an HTTP request in Inbucket
type Handler func(http.ResponseWriter, *http.Request, *Context) error
const (
staticDir = "static"
templateDir = "templates"
)
var (
// msgHub holds a reference to the message pub/sub system
msgHub *msghub.Hub
@@ -59,10 +65,10 @@ func Initialize(
manager = mm
// Content Paths
log.Infof("HTTP templates mapped to %q", conf.Web.TemplateDir)
log.Infof("HTTP static content mapped to %q", conf.Web.PublicDir)
staticPath := filepath.Join(conf.Web.UIDir, staticDir)
log.Infof("Web UI content mapped to path: %s", conf.Web.UIDir)
Router.PathPrefix("/public/").Handler(http.StripPrefix("/public/",
http.FileServer(http.Dir(conf.Web.PublicDir))))
http.FileServer(http.Dir(staticPath))))
http.Handle("/", Router)
// Session cookie setup
+3 -4
View File
@@ -5,7 +5,6 @@ import (
"net/http"
"path"
"path/filepath"
"strings"
"sync"
"github.com/jhillyerd/inbucket/pkg/log"
@@ -49,8 +48,7 @@ func ParseTemplate(name string, partial bool) (*template.Template, error) {
return t, nil
}
tempPath := strings.Replace(name, "/", string(filepath.Separator), -1)
tempFile := filepath.Join(rootConfig.Web.TemplateDir, tempPath)
tempFile := filepath.Join(rootConfig.Web.UIDir, templateDir, filepath.FromSlash(name))
log.Tracef("Parsing template %v", tempFile)
var err error
@@ -62,7 +60,8 @@ func ParseTemplate(name string, partial bool) (*template.Template, error) {
t, err = t.ParseFiles(tempFile)
} else {
t = template.New("_base.html").Funcs(TemplateFuncs)
t, err = t.ParseFiles(filepath.Join(rootConfig.Web.TemplateDir, "_base.html"), tempFile)
t, err = t.ParseFiles(
filepath.Join(rootConfig.Web.UIDir, templateDir, "_base.html"), tempFile)
}
if err != nil {
return nil, err
+2 -2
View File
@@ -7,8 +7,8 @@ type msgDone struct {
done chan struct{}
}
// enforceMaxSize will delete the oldest message until the entire mail store is equal to or less
// than Store.maxSize bytes.
// maxSizeEnforcer will delete the oldest message until the entire mail store is equal to or less
// than maxSize bytes.
func (s *Store) maxSizeEnforcer(maxSize int64) {
all := &list.List{}
curSize := int64(0)

Before

Width:  |  Height:  |  Size: 106 KiB

After

Width:  |  Height:  |  Size: 106 KiB

Some files were not shown because too many files have changed in this diff Show More