Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
84af8f8e13 | ||
|
|
01e3dfc6cf | ||
|
|
b8c9d28324 | ||
|
|
45ff7597ed | ||
|
|
a1feaff350 | ||
|
|
a4ade439a6 | ||
|
|
841f5dfcfa | ||
|
|
4dd09dacb4 | ||
|
|
42cb5221a1 | ||
|
|
1bc4d1188c |
@@ -4,13 +4,13 @@ stages:
|
|||||||
|
|
||||||
lint:
|
lint:
|
||||||
stage: test
|
stage: test
|
||||||
image: registry.gitlab.com/etke.cc/base
|
image: registry.gitlab.com/etke.cc/base/build
|
||||||
script:
|
script:
|
||||||
- make lint
|
- make lint
|
||||||
|
|
||||||
unit:
|
unit:
|
||||||
stage: test
|
stage: test
|
||||||
image: registry.gitlab.com/etke.cc/base
|
image: registry.gitlab.com/etke.cc/base/build
|
||||||
script:
|
script:
|
||||||
- make test
|
- make test
|
||||||
|
|
||||||
|
|||||||
10
Dockerfile
10
Dockerfile
@@ -1,20 +1,16 @@
|
|||||||
FROM registry.gitlab.com/etke.cc/base AS builder
|
FROM registry.gitlab.com/etke.cc/base/build AS builder
|
||||||
|
|
||||||
WORKDIR /postmoogle
|
WORKDIR /postmoogle
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN make build
|
RUN make build
|
||||||
|
|
||||||
FROM alpine:latest
|
FROM registry.gitlab.com/etke.cc/base/app
|
||||||
|
|
||||||
ENV POSTMOOGLE_DB_DSN /data/postmoogle.db
|
ENV POSTMOOGLE_DB_DSN /data/postmoogle.db
|
||||||
|
|
||||||
RUN apk --no-cache add ca-certificates tzdata olm && \
|
|
||||||
adduser -D -g '' postmoogle && \
|
|
||||||
mkdir /data && chown -R postmoogle /data
|
|
||||||
|
|
||||||
COPY --from=builder /postmoogle/postmoogle /bin/postmoogle
|
COPY --from=builder /postmoogle/postmoogle /bin/postmoogle
|
||||||
|
|
||||||
USER postmoogle
|
USER app
|
||||||
|
|
||||||
ENTRYPOINT ["/bin/postmoogle"]
|
ENTRYPOINT ["/bin/postmoogle"]
|
||||||
|
|
||||||
|
|||||||
2
Makefile
2
Makefile
@@ -50,4 +50,4 @@ login:
|
|||||||
# docker build
|
# docker build
|
||||||
docker:
|
docker:
|
||||||
docker buildx create --use
|
docker buildx create --use
|
||||||
docker buildx build --platform linux/arm/v7,linux/arm64/v8,linux/amd64 --push -t ${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG} .
|
docker buildx build --platform linux/arm64/v8,linux/amd64 --push -t ${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG} .
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ so you can use it to send emails from your apps and scripts as well.
|
|||||||
|
|
||||||
- [x] SMTP client
|
- [x] SMTP client
|
||||||
- [x] SMTP server (you can use Postmoogle as general purpose SMTP server to send emails from your scripts or apps)
|
- [x] SMTP server (you can use Postmoogle as general purpose SMTP server to send emails from your scripts or apps)
|
||||||
- [x] Send a message to matrix room with special format to send a new email
|
- [x] Send a message to matrix room with special format to send a new email, even to multiple email addresses at once
|
||||||
- [ ] Reply to matrix thread sends reply into email thread
|
- [ ] Reply to matrix thread sends reply into email thread
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
@@ -256,9 +256,7 @@ If you want to change them - check available options in the help message (`!pm h
|
|||||||
|
|
||||||
* **!pm spamcheck:mx** - only accept email from servers which seem prepared to receive it (those having valid MX records) (`true` - enable, `false` - disable)
|
* **!pm spamcheck:mx** - only accept email from servers which seem prepared to receive it (those having valid MX records) (`true` - enable, `false` - disable)
|
||||||
* **!pm spamcheck:smtp** - only accept email from servers which seem prepared to receive it (those listening on an SMTP port) (`true` - enable, `false` - disable)
|
* **!pm spamcheck:smtp** - only accept email from servers which seem prepared to receive it (those listening on an SMTP port) (`true` - enable, `false` - disable)
|
||||||
* **!pm spamlist:emails** - Get or set `spamlist:emails` of the room (comma-separated list), eg: `spammer@example.com,sspam@example.org`
|
* **!pm spamlist** - Get or set `spamlist` of the room (comma-separated list), eg: `spammer@example.com,*@spammer.org,noreply@*`
|
||||||
* **!pm spamlist:hosts** - Get or set `spamlist:hosts` of the room (comma-separated list), eg: `spammer.com,scammer.com,morespam.com`
|
|
||||||
* **!pm spamlist:mailboxes** - Get or set `spamlist:mailboxes` of the room (comma-separated list), eg: `notspam,noreply,no-reply`
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -157,28 +157,10 @@ func (b *Bot) initCommands() commandList {
|
|||||||
allowed: b.allowOwner,
|
allowed: b.allowOwner,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: roomOptionSpamlistEmails,
|
key: roomOptionSpamlist,
|
||||||
description: fmt.Sprintf(
|
description: fmt.Sprintf(
|
||||||
"Get or set `%s` of the room (comma-separated list), eg: `spammer@example.com,sspam@example.org`",
|
"Get or set `%s` of the room (comma-separated list), eg: `spammer@example.com,*@spammer.org,spam@*`",
|
||||||
roomOptionSpamlistEmails,
|
roomOptionSpamlist,
|
||||||
),
|
|
||||||
sanitizer: utils.SanitizeStringSlice,
|
|
||||||
allowed: b.allowOwner,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: roomOptionSpamlistHosts,
|
|
||||||
description: fmt.Sprintf(
|
|
||||||
"Get or set `%s` of the room (comma-separated list), eg: `spammer.com,scammer.com,morespam.com`",
|
|
||||||
roomOptionSpamlistHosts,
|
|
||||||
),
|
|
||||||
sanitizer: utils.SanitizeStringSlice,
|
|
||||||
allowed: b.allowOwner,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: roomOptionSpamlistLocalparts,
|
|
||||||
description: fmt.Sprintf(
|
|
||||||
"Get or set `%s` of the room (comma-separated list), eg: `notspam,noreply,no-reply`",
|
|
||||||
roomOptionSpamlistLocalparts,
|
|
||||||
),
|
),
|
||||||
sanitizer: utils.SanitizeStringSlice,
|
sanitizer: utils.SanitizeStringSlice,
|
||||||
allowed: b.allowOwner,
|
allowed: b.allowOwner,
|
||||||
@@ -355,11 +337,6 @@ func (b *Bot) runSend(ctx context.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !utils.AddressValid(to) {
|
|
||||||
b.Error(ctx, evt.RoomID, "email address is not valid")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
cfg, err := b.getRoomSettings(evt.RoomID)
|
cfg, err := b.getRoomSettings(evt.RoomID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Error(ctx, evt.RoomID, "failed to retrieve room settings: %v", err)
|
b.Error(ctx, evt.RoomID, "failed to retrieve room settings: %v", err)
|
||||||
@@ -372,16 +349,29 @@ func (b *Bot) runSend(ctx context.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tos := strings.Split(to, ",")
|
||||||
|
// validate first
|
||||||
|
for _, to := range tos {
|
||||||
|
if !utils.AddressValid(to) {
|
||||||
|
b.Error(ctx, evt.RoomID, "email address is not valid")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
from := mailbox + "@" + b.domain
|
from := mailbox + "@" + b.domain
|
||||||
ID := fmt.Sprintf("<%s@%s>", evt.ID, b.domain)
|
ID := fmt.Sprintf("<%s@%s>", evt.ID, b.domain)
|
||||||
|
for _, to := range tos {
|
||||||
data := utils.
|
data := utils.
|
||||||
NewEmail(ID, "", subject, from, to, body, "", nil).
|
NewEmail(ID, "", subject, from, to, body, "", nil).
|
||||||
Compose(b.getBotSettings().DKIMPrivateKey())
|
Compose(b.getBotSettings().DKIMPrivateKey())
|
||||||
err = b.mta.Send(from, to, data)
|
err = b.mta.Send(from, to, data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Error(ctx, evt.RoomID, "cannot send email: %v", err)
|
b.Error(ctx, evt.RoomID, "cannot send email to %s: %v", to, err)
|
||||||
return
|
} else {
|
||||||
|
b.SendNotice(ctx, evt.RoomID, "Email has been sent to "+to)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(tos) > 1 {
|
||||||
|
b.SendNotice(ctx, evt.RoomID, "All emails were sent.")
|
||||||
}
|
}
|
||||||
|
|
||||||
b.SendNotice(ctx, evt.RoomID, "Email has been sent")
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ func (b *Bot) setOption(ctx context.Context, name, value string) {
|
|||||||
|
|
||||||
evt := eventFromContext(ctx)
|
evt := eventFromContext(ctx)
|
||||||
if name == roomOptionMailbox {
|
if name == roomOptionMailbox {
|
||||||
existingID, ok := b.GetMapping(value)
|
existingID, ok := b.getMapping(value)
|
||||||
if ok && existingID != "" && existingID != evt.RoomID {
|
if ok && existingID != "" && existingID != evt.RoomID {
|
||||||
b.SendNotice(ctx, evt.RoomID, fmt.Sprintf("Mailbox `%s@%s` already taken, kupo", value, b.domain))
|
b.SendNotice(ctx, evt.RoomID, fmt.Sprintf("Mailbox `%s@%s` already taken, kupo", value, b.domain))
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ func (b *Bot) syncRooms() error {
|
|||||||
if serr != nil {
|
if serr != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
b.migrateRoomSettings(roomID)
|
||||||
mailbox := cfg.Mailbox()
|
mailbox := cfg.Mailbox()
|
||||||
if mailbox != "" {
|
if mailbox != "" {
|
||||||
b.rooms.Store(mailbox, roomID)
|
b.rooms.Store(mailbox, roomID)
|
||||||
|
|||||||
@@ -200,8 +200,10 @@ func (b *Bot) sendFiles(ctx context.Context, roomID id.RoomID, files []*utils.Fi
|
|||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
req := file.Convert()
|
req := file.Convert()
|
||||||
err := b.lp.SendFile(roomID, req, file.MsgType, utils.RelatesTo(!noThreads, parentID))
|
err := b.lp.SendFile(roomID, req, file.MsgType, utils.RelatesTo(!noThreads, parentID))
|
||||||
|
if err != nil {
|
||||||
b.Error(ctx, roomID, "cannot upload file %s: %v", req.FileName, err)
|
b.Error(ctx, roomID, "cannot upload file %s: %v", req.FileName, err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Bot) getThreadID(roomID id.RoomID, messageID string) id.EventID {
|
func (b *Bot) getThreadID(roomID id.RoomID, messageID string) id.EventID {
|
||||||
|
|||||||
@@ -25,9 +25,7 @@ const (
|
|||||||
roomOptionPassword = "password"
|
roomOptionPassword = "password"
|
||||||
roomOptionSpamcheckSMTP = "spamcheck:smtp"
|
roomOptionSpamcheckSMTP = "spamcheck:smtp"
|
||||||
roomOptionSpamcheckMX = "spamcheck:mx"
|
roomOptionSpamcheckMX = "spamcheck:mx"
|
||||||
roomOptionSpamlistEmails = "spamlist:emails"
|
roomOptionSpamlist = "spamlist"
|
||||||
roomOptionSpamlistHosts = "spamlist:hosts"
|
|
||||||
roomOptionSpamlistLocalparts = "spamlist:mailboxes"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type roomSettings map[string]string
|
type roomSettings map[string]string
|
||||||
@@ -90,16 +88,53 @@ func (s roomSettings) SpamcheckMX() bool {
|
|||||||
return utils.Bool(s.Get(roomOptionSpamcheckMX))
|
return utils.Bool(s.Get(roomOptionSpamcheckMX))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s roomSettings) SpamlistEmails() []string {
|
func (s roomSettings) Spamlist() []string {
|
||||||
return utils.StringSlice(s.Get(roomOptionSpamlistEmails))
|
return utils.StringSlice(s.Get(roomOptionSpamlist))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s roomSettings) SpamlistHosts() []string {
|
func (s roomSettings) migrateSpamlistSettings() {
|
||||||
return utils.StringSlice(s.Get(roomOptionSpamlistHosts))
|
uniq := map[string]struct{}{}
|
||||||
}
|
emails := utils.StringSlice(s.Get("spamlist:emails"))
|
||||||
|
localparts := utils.StringSlice(s.Get("spamlist:localparts"))
|
||||||
|
hosts := utils.StringSlice(s.Get("spamlist:hosts"))
|
||||||
|
list := utils.StringSlice(s.Get(roomOptionSpamlist))
|
||||||
|
delete(s, "spamlist:emails")
|
||||||
|
delete(s, "spamlist:localparts")
|
||||||
|
delete(s, "spamlist:hosts")
|
||||||
|
|
||||||
func (s roomSettings) SpamlistLocalparts() []string {
|
for _, email := range emails {
|
||||||
return utils.StringSlice(s.Get(roomOptionSpamlistLocalparts))
|
if email == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
uniq[email] = struct{}{}
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, localpart := range localparts {
|
||||||
|
if localpart == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
uniq[localpart+"@*"] = struct{}{}
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, host := range hosts {
|
||||||
|
if host == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
uniq["*@"+host] = struct{}{}
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, item := range list {
|
||||||
|
if item == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
uniq[item] = struct{}{}
|
||||||
|
}
|
||||||
|
|
||||||
|
spamlist := make([]string, 0, len(uniq))
|
||||||
|
for item := range uniq {
|
||||||
|
spamlist = append(spamlist, item)
|
||||||
|
}
|
||||||
|
s.Set(roomOptionSpamlist, strings.Join(spamlist, ","))
|
||||||
}
|
}
|
||||||
|
|
||||||
// ContentOptions converts room display settings to content options
|
// ContentOptions converts room display settings to content options
|
||||||
@@ -130,3 +165,20 @@ func (b *Bot) getRoomSettings(roomID id.RoomID) (roomSettings, error) {
|
|||||||
func (b *Bot) setRoomSettings(roomID id.RoomID, cfg roomSettings) error {
|
func (b *Bot) setRoomSettings(roomID id.RoomID, cfg roomSettings) error {
|
||||||
return utils.UnwrapError(b.lp.SetRoomAccountData(roomID, acRoomSettingsKey, cfg))
|
return utils.UnwrapError(b.lp.SetRoomAccountData(roomID, acRoomSettingsKey, cfg))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b *Bot) migrateRoomSettings(roomID id.RoomID) {
|
||||||
|
cfg, err := b.getRoomSettings(roomID)
|
||||||
|
if err != nil {
|
||||||
|
b.log.Error("cannot retrieve room settings: %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if cfg["spamlist:emails"] == "" && cfg["spamlist:localparts"] == "" && cfg["spamlist:hosts"] == "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
cfg.migrateSpamlistSettings()
|
||||||
|
err = b.setRoomSettings(roomID, cfg)
|
||||||
|
if err != nil {
|
||||||
|
b.log.Error("cannot migrate room settings: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
14
go.mod
14
go.mod
@@ -11,7 +11,7 @@ require (
|
|||||||
github.com/gabriel-vasile/mimetype v1.4.1
|
github.com/gabriel-vasile/mimetype v1.4.1
|
||||||
github.com/getsentry/sentry-go v0.13.0
|
github.com/getsentry/sentry-go v0.13.0
|
||||||
github.com/jhillyerd/enmime v0.10.0
|
github.com/jhillyerd/enmime v0.10.0
|
||||||
github.com/lib/pq v1.10.6
|
github.com/lib/pq v1.10.7
|
||||||
github.com/mattn/go-sqlite3 v1.14.15
|
github.com/mattn/go-sqlite3 v1.14.15
|
||||||
github.com/raja/argon2pw v1.0.2-0.20210910183755-a391af63bd39
|
github.com/raja/argon2pw v1.0.2-0.20210910183755-a391af63bd39
|
||||||
gitlab.com/etke.cc/go/env v1.0.0
|
gitlab.com/etke.cc/go/env v1.0.0
|
||||||
@@ -19,10 +19,10 @@ require (
|
|||||||
gitlab.com/etke.cc/go/mxidwc v1.0.0
|
gitlab.com/etke.cc/go/mxidwc v1.0.0
|
||||||
gitlab.com/etke.cc/go/secgen v1.1.1
|
gitlab.com/etke.cc/go/secgen v1.1.1
|
||||||
gitlab.com/etke.cc/go/trysmtp v1.0.0
|
gitlab.com/etke.cc/go/trysmtp v1.0.0
|
||||||
gitlab.com/etke.cc/go/validator v1.0.1
|
gitlab.com/etke.cc/go/validator v1.0.2
|
||||||
gitlab.com/etke.cc/linkpearl v0.0.0-20221012104738-a977907db8b9
|
gitlab.com/etke.cc/linkpearl v0.0.0-20221012104738-a977907db8b9
|
||||||
golang.org/x/net v0.0.0-20221004154528-8021a29435af
|
golang.org/x/net v0.0.0-20221014081412-f15817d10f9b
|
||||||
maunium.net/go/mautrix v0.12.1
|
maunium.net/go/mautrix v0.12.2
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
@@ -46,9 +46,9 @@ require (
|
|||||||
github.com/tidwall/match v1.1.1 // indirect
|
github.com/tidwall/match v1.1.1 // indirect
|
||||||
github.com/tidwall/pretty v1.2.1 // indirect
|
github.com/tidwall/pretty v1.2.1 // indirect
|
||||||
github.com/tidwall/sjson v1.2.5 // indirect
|
github.com/tidwall/sjson v1.2.5 // indirect
|
||||||
github.com/yuin/goldmark v1.4.13 // indirect
|
github.com/yuin/goldmark v1.5.2 // indirect
|
||||||
golang.org/x/crypto v0.0.0-20221010152910-d6f0a8c073c2 // indirect
|
golang.org/x/crypto v0.0.0-20221012134737-56aed061732a // indirect
|
||||||
golang.org/x/sys v0.0.0-20221010170243-090e33056c14 // indirect
|
golang.org/x/sys v0.0.0-20221013171732-95e765b1cc43 // indirect
|
||||||
golang.org/x/text v0.3.7 // indirect
|
golang.org/x/text v0.3.7 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
maunium.net/go/maulogger/v2 v2.3.2 // indirect
|
maunium.net/go/maulogger/v2 v2.3.2 // indirect
|
||||||
|
|||||||
28
go.sum
28
go.sum
@@ -38,8 +38,8 @@ github.com/jaytaylor/html2text v0.0.0-20200412013138-3577fbdbcff7 h1:g0fAGBisHaE
|
|||||||
github.com/jaytaylor/html2text v0.0.0-20200412013138-3577fbdbcff7/go.mod h1:CVKlgaMiht+LXvHG173ujK6JUhZXKb2u/BQtjPDIvyk=
|
github.com/jaytaylor/html2text v0.0.0-20200412013138-3577fbdbcff7/go.mod h1:CVKlgaMiht+LXvHG173ujK6JUhZXKb2u/BQtjPDIvyk=
|
||||||
github.com/jhillyerd/enmime v0.10.0 h1:DZEzhptPRBesvN3gf7K1BOh4rfpqdsdrEoxW1Edr/3s=
|
github.com/jhillyerd/enmime v0.10.0 h1:DZEzhptPRBesvN3gf7K1BOh4rfpqdsdrEoxW1Edr/3s=
|
||||||
github.com/jhillyerd/enmime v0.10.0/go.mod h1:Qpe8EEemJMFAF8+NZoWdpXvK2Yb9dRF0k/z6mkcDHsA=
|
github.com/jhillyerd/enmime v0.10.0/go.mod h1:Qpe8EEemJMFAF8+NZoWdpXvK2Yb9dRF0k/z6mkcDHsA=
|
||||||
github.com/lib/pq v1.10.6 h1:jbk+ZieJ0D7EVGJYpL9QTz7/YW6UHbmdnZWYyK5cdBs=
|
github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw=
|
||||||
github.com/lib/pq v1.10.6/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
||||||
github.com/martinlindhe/base36 v1.0.0/go.mod h1:+AtEs8xrBpCeYgSLoY/aJ6Wf37jtBuR0s35750M27+8=
|
github.com/martinlindhe/base36 v1.0.0/go.mod h1:+AtEs8xrBpCeYgSLoY/aJ6Wf37jtBuR0s35750M27+8=
|
||||||
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
|
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
|
||||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||||
@@ -85,8 +85,8 @@ github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
|
|||||||
github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
||||||
github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY=
|
github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY=
|
||||||
github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28=
|
github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28=
|
||||||
github.com/yuin/goldmark v1.4.13 h1:fVcFKWvrslecOb/tg+Cc05dkeYx540o0FuFt3nUVDoE=
|
github.com/yuin/goldmark v1.5.2 h1:ALmeCk/px5FSm1MAcFBAsVKZjDuMVj8Tm7FFIlMJnqU=
|
||||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
github.com/yuin/goldmark v1.5.2/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||||
gitlab.com/etke.cc/go/env v1.0.0 h1:J98BwzOuELnjsVPFvz5wa79L7IoRV9CmrS41xLYXtSw=
|
gitlab.com/etke.cc/go/env v1.0.0 h1:J98BwzOuELnjsVPFvz5wa79L7IoRV9CmrS41xLYXtSw=
|
||||||
gitlab.com/etke.cc/go/env v1.0.0/go.mod h1:e1l4RM5MA1sc0R1w/RBDAESWRwgo5cOG9gx8BKUn2C4=
|
gitlab.com/etke.cc/go/env v1.0.0/go.mod h1:e1l4RM5MA1sc0R1w/RBDAESWRwgo5cOG9gx8BKUn2C4=
|
||||||
gitlab.com/etke.cc/go/logger v1.1.0 h1:Yngp/DDLmJ0jJNLvLXrfan5Gi5QV+r7z6kCczTv8t4U=
|
gitlab.com/etke.cc/go/logger v1.1.0 h1:Yngp/DDLmJ0jJNLvLXrfan5Gi5QV+r7z6kCczTv8t4U=
|
||||||
@@ -97,18 +97,18 @@ gitlab.com/etke.cc/go/secgen v1.1.1 h1:RmKOki725HIhWJHzPtAc9X4YvBneczndchpMgoDkE
|
|||||||
gitlab.com/etke.cc/go/secgen v1.1.1/go.mod h1:3pJqRGeWApzx7qXjABqz2o2SMCNpKSZao/gXVdasqE8=
|
gitlab.com/etke.cc/go/secgen v1.1.1/go.mod h1:3pJqRGeWApzx7qXjABqz2o2SMCNpKSZao/gXVdasqE8=
|
||||||
gitlab.com/etke.cc/go/trysmtp v1.0.0 h1:f/7gSmzohKniVeLSLevI+ZsySYcPUGkT9cRlOTwjOr8=
|
gitlab.com/etke.cc/go/trysmtp v1.0.0 h1:f/7gSmzohKniVeLSLevI+ZsySYcPUGkT9cRlOTwjOr8=
|
||||||
gitlab.com/etke.cc/go/trysmtp v1.0.0/go.mod h1:KqRuIB2IPElEEbAxXmFyKtm7S5YiuEb4lxwWthccqyE=
|
gitlab.com/etke.cc/go/trysmtp v1.0.0/go.mod h1:KqRuIB2IPElEEbAxXmFyKtm7S5YiuEb4lxwWthccqyE=
|
||||||
gitlab.com/etke.cc/go/validator v1.0.1 h1:xp1tAzgCu9A1pga8rFUo7hODaEcCR1nkkodw96+dYuA=
|
gitlab.com/etke.cc/go/validator v1.0.2 h1:7iVHG9sh1Hz6YcNT+tTLDm60B2PVSz6eh9nh6KOx7LI=
|
||||||
gitlab.com/etke.cc/go/validator v1.0.1/go.mod h1:3vdssRG4LwgdTr9IHz9MjGSEO+3/FO9hXPGMuSeweJ8=
|
gitlab.com/etke.cc/go/validator v1.0.2/go.mod h1:3vdssRG4LwgdTr9IHz9MjGSEO+3/FO9hXPGMuSeweJ8=
|
||||||
gitlab.com/etke.cc/linkpearl v0.0.0-20221012104738-a977907db8b9 h1:CJyYRf4KGmaFJDBJS5NXkt9v5ICi/AHrJIIOinQD/os=
|
gitlab.com/etke.cc/linkpearl v0.0.0-20221012104738-a977907db8b9 h1:CJyYRf4KGmaFJDBJS5NXkt9v5ICi/AHrJIIOinQD/os=
|
||||||
gitlab.com/etke.cc/linkpearl v0.0.0-20221012104738-a977907db8b9/go.mod h1:HkUHUkhbkDueEJVc7h/zBfz2hjhl4xxjQKv9Itrdf9k=
|
gitlab.com/etke.cc/linkpearl v0.0.0-20221012104738-a977907db8b9/go.mod h1:HkUHUkhbkDueEJVc7h/zBfz2hjhl4xxjQKv9Itrdf9k=
|
||||||
golang.org/x/crypto v0.0.0-20220518034528-6f7dac969898/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
golang.org/x/crypto v0.0.0-20220518034528-6f7dac969898/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||||
golang.org/x/crypto v0.0.0-20221010152910-d6f0a8c073c2 h1:x8vtB3zMecnlqZIwJNUUpwYKYSqCz5jXbiyv0ZJJZeI=
|
golang.org/x/crypto v0.0.0-20221012134737-56aed061732a h1:NmSIgad6KjE6VvHciPZuNRTKxGhlPfD6OA87W/PLkqg=
|
||||||
golang.org/x/crypto v0.0.0-20221010152910-d6f0a8c073c2/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
golang.org/x/crypto v0.0.0-20221012134737-56aed061732a/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||||
golang.org/x/net v0.0.0-20210501142056-aec3718b3fa0/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
|
golang.org/x/net v0.0.0-20210501142056-aec3718b3fa0/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
|
||||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||||
golang.org/x/net v0.0.0-20221004154528-8021a29435af h1:wv66FM3rLZGPdxpYL+ApnDe2HzHcTFta3z5nsc13wI4=
|
golang.org/x/net v0.0.0-20221014081412-f15817d10f9b h1:tvrvnPFcdzp294diPnrdZZZ8XUt2Tyj7svb7X52iDuU=
|
||||||
golang.org/x/net v0.0.0-20221004154528-8021a29435af/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
|
golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
|
||||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
@@ -116,8 +116,8 @@ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBc
|
|||||||
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20221010170243-090e33056c14 h1:k5II8e6QD8mITdi+okbbmR/cIyEbeXLBhy5Ha4nevyc=
|
golang.org/x/sys v0.0.0-20221013171732-95e765b1cc43 h1:OK7RB6t2WQX54srQQYSXMW8dF5C6/8+oA/s5QBmmto4=
|
||||||
golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20221013171732-95e765b1cc43/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY=
|
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY=
|
||||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||||
@@ -133,5 +133,5 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
|||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
maunium.net/go/maulogger/v2 v2.3.2 h1:1XmIYmMd3PoQfp9J+PaHhpt80zpfmMqaShzUTC7FwY0=
|
maunium.net/go/maulogger/v2 v2.3.2 h1:1XmIYmMd3PoQfp9J+PaHhpt80zpfmMqaShzUTC7FwY0=
|
||||||
maunium.net/go/maulogger/v2 v2.3.2/go.mod h1:TYWy7wKwz/tIXTpsx8G3mZseIRiC5DoMxSZazOHy68A=
|
maunium.net/go/maulogger/v2 v2.3.2/go.mod h1:TYWy7wKwz/tIXTpsx8G3mZseIRiC5DoMxSZazOHy68A=
|
||||||
maunium.net/go/mautrix v0.12.1 h1:MLfkWkpRIgUn7lueDSlPwYOeIuGF+NrAHW0hInIuVAw=
|
maunium.net/go/mautrix v0.12.2 h1:HuIDgigR6VY2QUPyZADCwn8UZWYAqi31a77qd1jMPA4=
|
||||||
maunium.net/go/mautrix v0.12.1/go.mod h1:/jxQFIipObSsjZPH6o3xyUi8uoULz3Hfr/8p9loqpYE=
|
maunium.net/go/mautrix v0.12.2/go.mod h1:bCw45Qx/m9qsz7eazmbe7Rzq5ZbTPzwRE1UgX2S9DXs=
|
||||||
|
|||||||
@@ -82,16 +82,12 @@ func (s *msasession) parseAttachments(parts []*enmime.Part) []*utils.File {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *msasession) validate(options utils.IncomingFilteringOptions) bool {
|
func (s *msasession) validate(options utils.IncomingFilteringOptions) bool {
|
||||||
spam := validator.Spam{
|
|
||||||
Emails: options.SpamlistEmails(),
|
|
||||||
Hosts: options.SpamlistHosts(),
|
|
||||||
Localparts: options.SpamlistLocalparts(),
|
|
||||||
}
|
|
||||||
enforce := validator.Enforce{
|
enforce := validator.Enforce{
|
||||||
|
Email: true,
|
||||||
MX: options.SpamcheckMX(),
|
MX: options.SpamcheckMX(),
|
||||||
SMTP: options.SpamcheckMX(),
|
SMTP: options.SpamcheckMX(),
|
||||||
}
|
}
|
||||||
v := validator.New(spam, enforce, s.to, s.log)
|
v := validator.New(options.Spamlist(), enforce, s.to, s.log)
|
||||||
|
|
||||||
return v.Email(s.from)
|
return v.Email(s.from)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,9 +23,7 @@ type MTA interface {
|
|||||||
type IncomingFilteringOptions interface {
|
type IncomingFilteringOptions interface {
|
||||||
SpamcheckSMTP() bool
|
SpamcheckSMTP() bool
|
||||||
SpamcheckMX() bool
|
SpamcheckMX() bool
|
||||||
SpamlistEmails() []string
|
Spamlist() []string
|
||||||
SpamlistHosts() []string
|
|
||||||
SpamlistLocalparts() []string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Email object
|
// Email object
|
||||||
|
|||||||
Reference in New Issue
Block a user