Skip to content

Commit affe19b

Browse files
committed
Merge branch 'release/v1.16.0'
2 parents ebe9195 + eefa4f8 commit affe19b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+2102
-903
lines changed

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ jobs:
2626
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
2727
restore-keys: |
2828
${{ runner.os }}-go-
29-
- run: go test ./internal/storage ./server ./internal/tools ./internal/html2text -v
30-
- run: go test ./internal/storage ./internal/html2text -bench=.
29+
- run: go test -p 1 ./internal/storage ./server ./internal/tools ./internal/html2text -v
30+
- run: go test -p 1 ./internal/storage ./internal/html2text -bench=.
3131

3232
# build the assets
3333
- name: Build web UI

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,25 @@
22

33
Notable changes to Mailpit will be documented in this file.
44

5+
## [v1.16.0]
6+
7+
### Chore
8+
- Update caniemail test database
9+
- Update node dependencies
10+
- Update Go dependencies
11+
- Switch database flag/env to `--database` / `MP_DATABASE`
12+
13+
### Feature
14+
- Search support for before: and after: dates ([#252](https://github.com/axllent/mailpit/issues/252))
15+
- Add optional tenant ID to isolate data in shared databases ([#254](https://github.com/axllent/mailpit/issues/254))
16+
- Option to use rqlite database storage ([#254](https://github.com/axllent/mailpit/issues/254))
17+
18+
### Fix
19+
- Remove duplicated authentication check ([#276](https://github.com/axllent/mailpit/issues/276))
20+
- Prevent conditional JS error when global mailbox tag list is modified via auto/plus-address tagging while viewing a message
21+
- Extract plus addresses from email addresses only, not names
22+
23+
524
## [v1.15.1]
625

726
### Chore

cmd/readyz.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ settings to determine the HTTP bind interface & port.
4141
IdleConnTimeout: time.Second * 5,
4242
ExpectContinueTimeout: time.Second * 5,
4343
TLSHandshakeTimeout: time.Second * 5,
44-
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
44+
// do not verify TLS in case this instance is using HTTPS
45+
TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, // #nosec
4546
}
4647
client := &http.Client{Transport: conf}
4748

cmd/reindex.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ If you have several thousand messages in your mailbox, then it is advised to shu
1919
Mailpit while you reindex as this process will likely result in database locking issues.`,
2020
Args: cobra.ExactArgs(1),
2121
Run: func(cmd *cobra.Command, args []string) {
22-
config.DataFile = args[0]
22+
config.Database = args[0]
2323
config.MaxMessages = 0
2424

2525
if err := storage.InitDB(); err != nil {

cmd/root.go

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ func init() {
8080
// load environment variables
8181
initConfigFromEnv()
8282

83-
rootCmd.Flags().StringVarP(&config.DataFile, "db-file", "d", config.DataFile, "Database file to store persistent data")
83+
rootCmd.Flags().StringVarP(&config.Database, "database", "d", config.Database, "Database to store persistent data")
84+
rootCmd.Flags().StringVar(&config.TenantID, "tenant-id", config.TenantID, "Database tenant ID to isolate data")
8485
rootCmd.Flags().IntVarP(&config.MaxMessages, "max", "m", config.MaxMessages, "Max number of messages to store")
8586
rootCmd.Flags().BoolVar(&config.UseMessageDates, "use-message-dates", config.UseMessageDates, "Use message dates as the received dates")
8687
rootCmd.Flags().BoolVar(&config.IgnoreDuplicateIDs, "ignore-duplicate-ids", config.IgnoreDuplicateIDs, "Ignore duplicate messages (by Message-Id)")
@@ -132,6 +133,10 @@ func init() {
132133
rootCmd.Flags().StringVar(&config.WebhookURL, "webhook-url", config.WebhookURL, "Send a webhook request for new messages")
133134
rootCmd.Flags().IntVar(&webhook.RateLimit, "webhook-limit", webhook.RateLimit, "Limit webhook requests per second")
134135

136+
// DEPRECATED FLAG 2024/04/12 - but will not be removed to maintain backwards compatibility
137+
rootCmd.Flags().StringVar(&config.Database, "db-file", config.Database, "Database file to store persistent data")
138+
rootCmd.Flags().Lookup("db-file").Hidden = true
139+
135140
// DEPRECATED FLAGS 2023/03/12
136141
rootCmd.Flags().StringVar(&config.UITLSCert, "ui-ssl-cert", config.UITLSCert, "SSL certificate for web UI - requires ui-ssl-key")
137142
rootCmd.Flags().StringVar(&config.UITLSKey, "ui-ssl-key", config.UITLSKey, "SSL key for web UI - requires ui-ssl-cert")
@@ -155,7 +160,12 @@ func init() {
155160
// Load settings from environment
156161
func initConfigFromEnv() {
157162
// General
158-
config.DataFile = os.Getenv("MP_DATA_FILE")
163+
if len(os.Getenv("MP_DATABASE")) > 0 {
164+
config.Database = os.Getenv("MP_DATABASE")
165+
}
166+
167+
config.TenantID = os.Getenv("MP_TENANT_ID")
168+
159169
if len(os.Getenv("MP_MAX_MESSAGES")) > 0 {
160170
config.MaxMessages, _ = strconv.Atoi(os.Getenv("MP_MAX_MESSAGES"))
161171
}
@@ -223,7 +233,6 @@ func initConfigFromEnv() {
223233
if getEnabledFromEnv("MP_SMTP_REQUIRE_TLS") {
224234
config.SMTPRequireTLS = true
225235
}
226-
227236
if getEnabledFromEnv("MP_SMTP_AUTH_ALLOW_INSECURE") {
228237
config.SMTPAuthAllowInsecure = true
229238
}
@@ -289,6 +298,11 @@ func initConfigFromEnv() {
289298

290299
// load deprecated settings from environment and warn
291300
func initDeprecatedConfigFromEnv() {
301+
// deprecated 2024/04/12 - but will not be removed to maintain backwards compatibility
302+
if len(os.Getenv("MP_DATA_FILE")) > 0 {
303+
config.Database = os.Getenv("MP_DATA_FILE")
304+
}
305+
292306
// deprecated 2023/03/12
293307
if len(os.Getenv("MP_UI_SSL_CERT")) > 0 {
294308
logger.Log().Warn("ENV MP_UI_SSL_CERT has been deprecated, use MP_UI_TLS_CERT")

config/config.go

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,12 @@ var (
2626
// HTTPListen to listen on <interface>:<port>
2727
HTTPListen = "[::]:8025"
2828

29-
// DataFile for mail (optional)
30-
DataFile string
29+
// Database for mail (optional)
30+
Database string
31+
32+
// TenantID is an optional prefix to be applied to all database tables,
33+
// allowing multiple isolated instances of Mailpit to share a database.
34+
TenantID = ""
3135

3236
// MaxMessages is the maximum number of messages a mailbox can have (auto-pruned every minute)
3337
MaxMessages = 500
@@ -185,8 +189,18 @@ func VerifyConfig() error {
185189
cssFontRestriction, cssFontRestriction,
186190
)
187191

188-
if DataFile != "" && isDir(DataFile) {
189-
DataFile = filepath.Join(DataFile, "mailpit.db")
192+
if Database != "" && isDir(Database) {
193+
Database = filepath.Join(Database, "mailpit.db")
194+
}
195+
196+
TenantID = strings.TrimSpace(TenantID)
197+
if TenantID != "" {
198+
logger.Log().Infof("[db] using tenant \"%s\"", TenantID)
199+
re := regexp.MustCompile(`[^a-zA-Z0-9\_]`)
200+
TenantID = re.ReplaceAllString(TenantID, "_")
201+
if !strings.HasSuffix(TenantID, "_") {
202+
TenantID = TenantID + "_"
203+
}
190204
}
191205

192206
re := regexp.MustCompile(`.*:\d+$`)

go.mod

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,36 @@ module github.com/axllent/mailpit
33
go 1.20
44

55
require (
6-
github.com/GuiaBolso/darwin v0.0.0-20191218124601-fd6d2aa3d244
76
github.com/PuerkitoBio/goquery v1.9.1
7+
github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de
88
github.com/axllent/semver v0.0.1
99
github.com/disintegration/imaging v1.6.2
10-
github.com/gomarkdown/markdown v0.0.0-20231222211730-1d6d20845b47
10+
github.com/gomarkdown/markdown v0.0.0-20240328165702-4d01890c35c0
1111
github.com/gorilla/mux v1.8.1
1212
github.com/gorilla/websocket v1.5.1
1313
github.com/jhillyerd/enmime v1.2.0
14-
github.com/klauspost/compress v1.17.7
14+
github.com/klauspost/compress v1.17.8
1515
github.com/leporo/sqlf v1.4.0
1616
github.com/lithammer/shortuuid/v4 v4.0.0
1717
github.com/mhale/smtpd v0.8.2
1818
github.com/reiver/go-telnet v0.0.0-20180421082511-9ff0b2ab096e
19+
github.com/rqlite/gorqlite v0.0.0-20240227123050-397b03f02418
1920
github.com/sirupsen/logrus v1.9.3
2021
github.com/spf13/cobra v1.8.0
2122
github.com/spf13/pflag v1.0.5
2223
github.com/tg123/go-htpasswd v1.2.2
2324
github.com/vanng822/go-premailer v1.20.2
24-
golang.org/x/net v0.22.0
25+
golang.org/x/net v0.24.0
2526
golang.org/x/text v0.14.0
2627
golang.org/x/time v0.5.0
2728
gopkg.in/yaml.v3 v3.0.1
28-
modernc.org/sqlite v1.29.5
29+
modernc.org/sqlite v1.29.6
2930
)
3031

3132
require (
32-
github.com/DATA-DOG/go-sqlmock v1.5.0 // indirect
3333
github.com/GehirnInc/crypt v0.0.0-20230320061759-8cc1b52080c5 // indirect
3434
github.com/andybalholm/cascadia v1.3.2 // indirect
3535
github.com/cention-sany/utf7 v0.0.0-20170124080048-26cad61bd60a // indirect
36-
github.com/cznic/ql v1.2.0 // indirect
3736
github.com/dustin/go-humanize v1.0.1 // indirect
3837
github.com/gogs/chardet v0.0.0-20211120154057-b7413eaefb8f // indirect
3938
github.com/google/uuid v1.6.0 // indirect
@@ -53,14 +52,14 @@ require (
5352
github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf // indirect
5453
github.com/valyala/bytebufferpool v1.0.0 // indirect
5554
github.com/vanng822/css v1.0.1 // indirect
56-
golang.org/x/crypto v0.21.0 // indirect
55+
golang.org/x/crypto v0.22.0 // indirect
5756
golang.org/x/image v0.15.0 // indirect
58-
golang.org/x/sys v0.18.0 // indirect
57+
golang.org/x/sys v0.19.0 // indirect
5958
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
6059
modernc.org/gc/v3 v3.0.0-20240304020402-f0dba7c97c2b // indirect
61-
modernc.org/libc v1.45.0 // indirect
60+
modernc.org/libc v1.49.3 // indirect
6261
modernc.org/mathutil v1.6.0 // indirect
63-
modernc.org/memory v1.7.2 // indirect
62+
modernc.org/memory v1.8.0 // indirect
6463
modernc.org/strutil v1.2.0 // indirect
6564
modernc.org/token v1.1.0 // indirect
6665
)

0 commit comments

Comments
 (0)