From 962580710685224fa1143ad5beb097a61151ce51 Mon Sep 17 00:00:00 2001 From: "Felipe M." Date: Sun, 24 Nov 2024 13:56:12 +0100 Subject: [PATCH 01/20] chore: updated readme with links to shoutrrr docs --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1b62f59..e9deefe 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # smtp2Shoutrrr -A simple SMTP server that forwards incoming emails to a Shoutrrr service. +A simple SMTP server that forwards incoming emails to a [Shoutrrr supported service](https://containrrr.dev/shoutrrr/). ## Installing @@ -20,6 +20,7 @@ Password = "nometokens" # Email addresses to forward emails from Addresses = ["some@email.com"] # Shoutrrr service to forward emails to +# See shoutrrr documentation: https://containrrr.dev/shoutrrr/ Target = "ntfy://ntfy.sh/my-ntfy-topic?tags=thing" # Note: Repeat [[Recipients]] as needed From 31f2102031d35462c773aae66edbd403b2def004 Mon Sep 17 00:00:00 2001 From: "Felipe M. (aider)" Date: Mon, 2 Dec 2024 16:23:49 +0100 Subject: [PATCH 02/20] refactor: Reorganize SMTP2Shoutrrr code into separate files --- backend.go | 116 ++++++++++++++++++++ cmd/smtp2shoutrrr/main.go | 223 +------------------------------------- email.go | 65 +++++++++++ server.go | 50 +++++++++ 4 files changed, 232 insertions(+), 222 deletions(-) create mode 100644 backend.go create mode 100644 email.go create mode 100644 server.go diff --git a/backend.go b/backend.go new file mode 100644 index 0000000..ddcf792 --- /dev/null +++ b/backend.go @@ -0,0 +1,116 @@ +package smtp2shoutrrr + +import ( + "fmt" + "io" + "log/slog" + "net/mail" + "net/url" + "slices" + "strings" + + "github.com/containrrr/shoutrrr" + "github.com/emersion/go-sasl" + "github.com/emersion/go-smtp" +) + +type Backend struct { + config *Config +} + +func (bkd *Backend) NewSession(c *smtp.Conn) (smtp.Session, error) { + return &Session{ + forwarderFunc: bkd.forwardEmail, + config: bkd.config, + }, nil +} + +func (bkd *Backend) forwardEmail(email ReceivedEmail) error { + slog.Info("forwading message", slog.String("to", strings.Join(email.Recipients, ","))) + + for _, r := range bkd.config.Recipients { + for _, a := range email.Recipients { + if slices.Contains(r.Addresses, a) { + urlParams := url.Values{ + "title": {email.Msg.Header.Get("Subject")}, + } + + destinationURL := r.GetTargetURL() + destinationURL.RawQuery = urlParams.Encode() + + body, err := email.Body() + if err != nil { + slog.Error("Error getting email body", slog.String("err", err.Error())) + continue + } + + if err := shoutrrr.Send(destinationURL.String(), body); err != nil { + slog.Error("Error sending message", slog.String("err", err.Error())) + continue + } + + break + } + } + } + + return nil +} + +type Session struct { + addresses []string + body string + + config *Config + + forwarderFunc func(ReceivedEmail) error +} + +func (s *Session) AuthMechanisms() []string { + return []string{sasl.Plain} +} + +func (s *Session) Auth(mech string) (sasl.Server, error) { + return sasl.NewPlainServer(func(identity, username, password string) error { + if username != s.config.Username && password != s.config.Password { + return fmt.Errorf("invalid credentials") + } + return nil + }), nil +} + +func (s *Session) Mail(from string, opts *smtp.MailOptions) error { + slog.Debug("Mail from", slog.String("from", from)) + return nil +} + +func (s *Session) Rcpt(to string, opts *smtp.RcptOptions) error { + slog.Debug("Rcpt to", slog.String("to", to)) + s.addresses = append(s.addresses, to) + return nil +} + +func (s *Session) Data(r io.Reader) error { + msg, err := mail.ReadMessage(r) + if err != nil { + slog.Error("Error reading data", slog.String("err", err.Error())) + return fmt.Errorf("Error reading data: %w", err) + } + + slog.Info("Received email", slog.String("destination", strings.Join(s.addresses, ","))) + + if err := s.forwarderFunc(ReceivedEmail{ + Recipients: s.addresses, + Msg: msg, + }); err != nil { + slog.Error("Error forwarding email", slog.String("err", err.Error())) + } + + return nil +} + +func (s *Session) Reset() {} + +func (s *Session) Logout() error { + return nil +} diff --git a/cmd/smtp2shoutrrr/main.go b/cmd/smtp2shoutrrr/main.go index ef2c937..4e1b84a 100644 --- a/cmd/smtp2shoutrrr/main.go +++ b/cmd/smtp2shoutrrr/main.go @@ -1,236 +1,15 @@ package main import ( - "bytes" "context" - "fmt" - "io" - "log" "log/slog" - "mime" - "mime/multipart" - "net/mail" - "net/url" "os" - "slices" - "strings" - "time" "git.nakama.town/fmartingr/gotoolkit/encoding" - "git.nakama.town/fmartingr/gotoolkit/model" "git.nakama.town/fmartingr/gotoolkit/service" - "github.com/containrrr/shoutrrr" - "github.com/emersion/go-sasl" - "github.com/emersion/go-smtp" - "git.nakama.town/fmartingr/smtp2shoutrrr" ) -type ReceivedEmail struct { - Recipients []string - Msg *mail.Message - body string -} - -func (re *ReceivedEmail) Body() (string, error) { - if re.body == "" { - // Get the Content-Type header - contentType := re.Msg.Header.Get("Content-Type") - - if contentType == "" { - body, err := io.ReadAll(re.Msg.Body) - if err != nil { - return "", fmt.Errorf("failed to read email body: %w", err) - } - re.body = string(body) - } else { - mediaType, params, err := mime.ParseMediaType(contentType) - if err != nil { - log.Fatalf("Failed to parse Content-Type: %v", err) - } - - if strings.HasPrefix(mediaType, "multipart/alternative") { - // Parse the multipart message - mr := multipart.NewReader(re.Msg.Body, params["boundary"]) - for { - part, err := mr.NextPart() - if err != nil { - break // End of parts - } - defer part.Close() - - // Print part headers - fmt.Printf("Part Content-Type: %s\n", part.Header.Get("Content-Type")) - - // Set body if this is the text/plain part - if strings.HasPrefix(part.Header.Get("Content-Type"), "text/plain") { - // Read the part's body - body := new(bytes.Buffer) - _, err = body.ReadFrom(part) - if err != nil { - slog.Error("Failed to read part body", slog.String("err", err.Error())) - return "", fmt.Errorf("failed to read part body: %w", err) - } - - re.body = body.String() - break - } - } - } - } - } - - return re.body, nil -} - -var _ model.Server = (*smtpServer)(nil) - -type smtpServer struct { - backend *smtp.Server - config smtp2shoutrrr.Config -} - -func (s *smtpServer) IsEnabled() bool { - return true -} - -func (s *smtpServer) Start(_ context.Context) error { - slog.Info("Started SMTP server", slog.String("addr", s.backend.Addr)) - return s.backend.ListenAndServe() -} - -func (s *smtpServer) Stop(ctx context.Context) error { - slog.Info("Stopping SMTP server") - return s.backend.Shutdown(ctx) -} - -func NewSMTPServer(config *smtp2shoutrrr.Config) model.Server { - be := &Backend{ - config: config, - } - - smtpBackend := smtp.NewServer(be) - smtpBackend.Addr = fmt.Sprintf(":%d", config.Port) - // smtpBackend.Domain = "localhost" - smtpBackend.WriteTimeout = 10 * time.Second - smtpBackend.ReadTimeout = 10 * time.Second - smtpBackend.MaxMessageBytes = 1024 * 1024 - smtpBackend.MaxRecipients = 50 - smtpBackend.AllowInsecureAuth = true - - return &smtpServer{ - backend: smtpBackend, - } -} - -// The Backend implements SMTP server methods. -type Backend struct { - config *smtp2shoutrrr.Config -} - -// NewSession is called after client greeting (EHLO, HELO). -func (bkd *Backend) NewSession(c *smtp.Conn) (smtp.Session, error) { - return &Session{ - forwarderFunc: bkd.forwardEmail, - config: bkd.config, - }, nil -} - -func (bkd *Backend) forwardEmail(email ReceivedEmail) error { - slog.Info("forwading message", slog.String("to", strings.Join(email.Recipients, ","))) - - for _, r := range bkd.config.Recipients { - for _, a := range email.Recipients { - if slices.Contains(r.Addresses, a) { - urlParams := url.Values{ - "title": {email.Msg.Header.Get("Subject")}, - } - - destinationURL := r.GetTargetURL() - destinationURL.RawQuery = urlParams.Encode() - - body, err := email.Body() - if err != nil { - slog.Error("Error getting email body", slog.String("err", err.Error())) - continue - } - - if err := shoutrrr.Send(destinationURL.String(), body); err != nil { - slog.Error("Error sending message", slog.String("err", err.Error())) - continue - } - - // Already sent via this configuration, go to the next - break - } - } - } - - return nil -} - -// A Session is returned after successful login. -type Session struct { - addresses []string - body string - - config *smtp2shoutrrr.Config - - forwarderFunc func(ReceivedEmail) error -} - -// AuthMechanisms returns a slice of available auth mechanisms; only PLAIN is -// supported in this example. -func (s *Session) AuthMechanisms() []string { - return []string{sasl.Plain} -} - -// Auth is the handler for supported authenticators. -func (s *Session) Auth(mech string) (sasl.Server, error) { - return sasl.NewPlainServer(func(identity, username, password string) error { - if username != s.config.Username && password != s.config.Password { - return fmt.Errorf("invalid credentials") - } - return nil - }), nil -} - -func (s *Session) Mail(from string, opts *smtp.MailOptions) error { - slog.Debug("Mail from", slog.String("from", from)) - return nil -} - -func (s *Session) Rcpt(to string, opts *smtp.RcptOptions) error { - slog.Debug("Rcpt to", slog.String("to", to)) - s.addresses = append(s.addresses, to) - return nil -} - -func (s *Session) Data(r io.Reader) error { - msg, err := mail.ReadMessage(r) - if err != nil { - slog.Error("Error reading data", slog.String("err", err.Error())) - return fmt.Errorf("Error reading data: %w", err) - } - - slog.Info("Received email", slog.String("destination", strings.Join(s.addresses, ","))) - - if err := s.forwarderFunc(ReceivedEmail{ - Recipients: s.addresses, - Msg: msg, - }); err != nil { - slog.Error("Error forwarding email", slog.String("err", err.Error())) - } - - return nil -} - -func (s *Session) Reset() {} - -func (s *Session) Logout() error { - return nil -} - func main() { var config *smtp2shoutrrr.Config configPath := "config.toml" @@ -252,7 +31,7 @@ func main() { slog.Info("config loaded", slog.Int("recipients", len(config.Recipients))) ctx := context.Background() - smtpServer := NewSMTPServer(config) + smtpServer := smtp2shoutrrr.NewSMTPServer(config) svc, err := service.NewService([]model.Server{ smtpServer, diff --git a/email.go b/email.go new file mode 100644 index 0000000..bd2fa6a --- /dev/null +++ b/email.go @@ -0,0 +1,65 @@ +package smtp2shoutrrr + +import ( + "bytes" + "fmt" + "io" + "log" + "log/slog" + "mime" + "mime/multipart" + "net/mail" + "strings" +) + +type ReceivedEmail struct { + Recipients []string + Msg *mail.Message + body string +} + +func (re *ReceivedEmail) Body() (string, error) { + if re.body == "" { + contentType := re.Msg.Header.Get("Content-Type") + + if contentType == "" { + body, err := io.ReadAll(re.Msg.Body) + if err != nil { + return "", fmt.Errorf("failed to read email body: %w", err) + } + re.body = string(body) + } else { + mediaType, params, err := mime.ParseMediaType(contentType) + if err != nil { + log.Fatalf("Failed to parse Content-Type: %v", err) + } + + if strings.HasPrefix(mediaType, "multipart/alternative") { + mr := multipart.NewReader(re.Msg.Body, params["boundary"]) + for { + part, err := mr.NextPart() + if err != nil { + break + } + defer part.Close() + + fmt.Printf("Part Content-Type: %s\n", part.Header.Get("Content-Type")) + + if strings.HasPrefix(part.Header.Get("Content-Type"), "text/plain") { + body := new(bytes.Buffer) + _, err = body.ReadFrom(part) + if err != nil { + slog.Error("Failed to read part body", slog.String("err", err.Error())) + return "", fmt.Errorf("failed to read part body: %w", err) + } + + re.body = body.String() + break + } + } + } + } + } + + return re.body, nil +} diff --git a/server.go b/server.go new file mode 100644 index 0000000..afaa4a7 --- /dev/null +++ b/server.go @@ -0,0 +1,50 @@ +package smtp2shoutrrr + +import ( + "context" + "fmt" + "log/slog" + "time" + + "git.nakama.town/fmartingr/gotoolkit/model" + "github.com/emersion/go-smtp" +) + +var _ model.Server = (*smtpServer)(nil) + +type smtpServer struct { + backend *smtp.Server + config Config +} + +func (s *smtpServer) IsEnabled() bool { + return true +} + +func (s *smtpServer) Start(_ context.Context) error { + slog.Info("Started SMTP server", slog.String("addr", s.backend.Addr)) + return s.backend.ListenAndServe() +} + +func (s *smtpServer) Stop(ctx context.Context) error { + slog.Info("Stopping SMTP server") + return s.backend.Shutdown(ctx) +} + +func NewSMTPServer(config *Config) model.Server { + be := &Backend{ + config: config, + } + + smtpBackend := smtp.NewServer(be) + smtpBackend.Addr = fmt.Sprintf(":%d", config.Port) + smtpBackend.WriteTimeout = 10 * time.Second + smtpBackend.ReadTimeout = 10 * time.Second + smtpBackend.MaxMessageBytes = 1024 * 1024 + smtpBackend.MaxRecipients = 50 + smtpBackend.AllowInsecureAuth = true + + return &smtpServer{ + backend: smtpBackend, + } +} From cfebaf09e38e6c91f34875f7d27016e0ed2e1464 Mon Sep 17 00:00:00 2001 From: "Felipe M. (aider)" Date: Mon, 2 Dec 2024 16:29:03 +0100 Subject: [PATCH 03/20] feat: Add catch-all recipient configuration to Config struct --- config.go | 1 + 1 file changed, 1 insertion(+) diff --git a/config.go b/config.go index 9a64e9f..f1711ca 100644 --- a/config.go +++ b/config.go @@ -10,6 +10,7 @@ type Config struct { Username string Password string Recipients []ConfigRecipient + CatchAll *ConfigRecipient } func (c *Config) SetDefaults() { From a2b696471ce0aeee1610ca11513b742d5f2877e0 Mon Sep 17 00:00:00 2001 From: "Felipe M. (aider)" Date: Mon, 2 Dec 2024 16:30:43 +0100 Subject: [PATCH 04/20] feat: Add catch-all recipient support for unmatched email addresses --- backend.go | 55 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 17 deletions(-) diff --git a/backend.go b/backend.go index ddcf792..ce529e3 100644 --- a/backend.go +++ b/backend.go @@ -18,6 +18,28 @@ type Backend struct { config *Config } +func (bkd *Backend) sendNotification(recipient ConfigRecipient, email ReceivedEmail) error { + urlParams := url.Values{ + "title": {email.Msg.Header.Get("Subject")}, + } + + destinationURL := recipient.GetTargetURL() + destinationURL.RawQuery = urlParams.Encode() + + body, err := email.Body() + if err != nil { + slog.Error("Error getting email body", slog.String("err", err.Error())) + return fmt.Errorf("failed to get email body: %w", err) + } + + if err := shoutrrr.Send(destinationURL.String(), body); err != nil { + slog.Error("Error sending message", slog.String("err", err.Error())) + return fmt.Errorf("failed to send notification: %w", err) + } + + return nil +} + func (bkd *Backend) NewSession(c *smtp.Conn) (smtp.Session, error) { return &Session{ forwarderFunc: bkd.forwardEmail, @@ -28,30 +50,29 @@ func (bkd *Backend) NewSession(c *smtp.Conn) (smtp.Session, error) { func (bkd *Backend) forwardEmail(email ReceivedEmail) error { slog.Info("forwading message", slog.String("to", strings.Join(email.Recipients, ","))) + // Try to match configured recipients first + matched := false for _, r := range bkd.config.Recipients { for _, a := range email.Recipients { if slices.Contains(r.Addresses, a) { - urlParams := url.Values{ - "title": {email.Msg.Header.Get("Subject")}, + if err := bkd.sendNotification(r, email); err != nil { + return err } - - destinationURL := r.GetTargetURL() - destinationURL.RawQuery = urlParams.Encode() - - body, err := email.Body() - if err != nil { - slog.Error("Error getting email body", slog.String("err", err.Error())) - continue - } - - if err := shoutrrr.Send(destinationURL.String(), body); err != nil { - slog.Error("Error sending message", slog.String("err", err.Error())) - continue - } - + matched = true break } } + if matched { + break + } + } + + // If no recipient matched and catch-all is configured, use it + if !matched && bkd.config.CatchAll != nil { + slog.Info("using catch-all recipient for unmatched email") + if err := bkd.sendNotification(*bkd.config.CatchAll, email); err != nil { + return err + } } return nil From 4ace8af18b82e180c088ac65994769cb300b5d95 Mon Sep 17 00:00:00 2001 From: "Felipe M." Date: Mon, 2 Dec 2024 16:31:58 +0100 Subject: [PATCH 05/20] fix: missing import (aider fix) --- cmd/smtp2shoutrrr/main.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/smtp2shoutrrr/main.go b/cmd/smtp2shoutrrr/main.go index 4e1b84a..ff48845 100644 --- a/cmd/smtp2shoutrrr/main.go +++ b/cmd/smtp2shoutrrr/main.go @@ -6,6 +6,7 @@ import ( "os" "git.nakama.town/fmartingr/gotoolkit/encoding" + "git.nakama.town/fmartingr/gotoolkit/model" "git.nakama.town/fmartingr/gotoolkit/service" "git.nakama.town/fmartingr/smtp2shoutrrr" ) From 787b0f99fc8bb08340ca1418c208d1dcb2f6f12b Mon Sep 17 00:00:00 2001 From: "Felipe M." Date: Mon, 2 Dec 2024 16:32:11 +0100 Subject: [PATCH 06/20] fix: ignore recipient if no target is set (aider fix) --- backend.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/backend.go b/backend.go index ce529e3..baba722 100644 --- a/backend.go +++ b/backend.go @@ -19,6 +19,11 @@ type Backend struct { } func (bkd *Backend) sendNotification(recipient ConfigRecipient, email ReceivedEmail) error { + if recipient.Target == "" { + slog.Warn("no target provided for recipient", slog.String("recipient", strings.Join(recipient.Addresses, ","))) + return nil + } + urlParams := url.Values{ "title": {email.Msg.Header.Get("Subject")}, } From 57acca06213d8bb2564b04c34e3606dfddabaf15 Mon Sep 17 00:00:00 2001 From: "Felipe M." Date: Mon, 2 Dec 2024 16:32:32 +0100 Subject: [PATCH 07/20] chore: ignore aider files --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 00a88f1..7a7ec77 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,4 @@ dist/ # smtp2shoutrrr config.toml +.aider* From a00f64e43c0fbc7b805b7f3a629fef6e844dad93 Mon Sep 17 00:00:00 2001 From: "Felipe M." Date: Mon, 2 Dec 2024 16:32:40 +0100 Subject: [PATCH 08/20] chore: add some disclaimer to containerfile --- Containerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Containerfile b/Containerfile index ad06a9a..9fa3ce9 100644 --- a/Containerfile +++ b/Containerfile @@ -1,3 +1,5 @@ +# This file is used directly by the goreleaser build +# It is used to build the final container image FROM scratch COPY /smtp2shoutrrr /usr/bin/smtp2shoutrrr ENTRYPOINT ["/usr/bin/smtp2shoutrrr"] From aa1fd99ffd6f473248dc79baa39c33dec1041cd4 Mon Sep 17 00:00:00 2001 From: "Felipe M." Date: Mon, 2 Dec 2024 16:32:49 +0100 Subject: [PATCH 09/20] chore: unused vars in makefile --- Makefile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Makefile b/Makefile index 8daaabb..90d86e1 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,6 @@ CGO_ENABLED := 0 BUILDS_PATH := ./dist FROM_MAKEFILE := y -CONTAINER_RUNTIME := podman CONTAINERFILE_NAME := Containerfile CONTAINER_ALPINE_VERSION := 3.20 CONTAINER_SOURCE_URL := "https://git.nakama.town/fmartingr/${PROJECT_NAME}" @@ -31,7 +30,6 @@ export TEST_OPTIONS export TEST_TIMEOUT export BUILDS_PATH -export CONTAINER_RUNTIME export CONTAINERFILE_NAME export CONTAINER_ALPINE_VERSION export CONTAINER_SOURCE_URL From bd8a3395e9a97e15e09c201810f3b54dd6fae3df Mon Sep 17 00:00:00 2001 From: "Felipe M. (aider)" Date: Mon, 2 Dec 2024 16:33:48 +0100 Subject: [PATCH 10/20] docs: Add catch-all recipient configuration to README --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index e9deefe..76c1bcb 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,11 @@ Addresses = ["some@email.com"] Target = "ntfy://ntfy.sh/my-ntfy-topic?tags=thing" # Note: Repeat [[Recipients]] as needed + +# Optional: Configure a catch-all recipient for unmatched email addresses +[CatchAll] +# Shoutrrr service to forward unmatched emails to +Target = "ntfy://ntfy.sh/catch-all-topic?tags=unmatched" ``` ### From releases From 4d7abab4d4e2bc68b7365335af52b8da393fa72b Mon Sep 17 00:00:00 2001 From: "Felipe M." Date: Mon, 27 Jan 2025 21:12:50 +0100 Subject: [PATCH 11/20] fix: bundle ca-certs directly in the binary --- Containerfile | 1 + cmd/smtp2shoutrrr/main.go | 2 ++ go.mod | 1 + go.sum | 2 ++ 4 files changed, 6 insertions(+) diff --git a/Containerfile b/Containerfile index 9fa3ce9..2284c9e 100644 --- a/Containerfile +++ b/Containerfile @@ -1,5 +1,6 @@ # This file is used directly by the goreleaser build # It is used to build the final container image FROM scratch +WORKDIR / COPY /smtp2shoutrrr /usr/bin/smtp2shoutrrr ENTRYPOINT ["/usr/bin/smtp2shoutrrr"] diff --git a/cmd/smtp2shoutrrr/main.go b/cmd/smtp2shoutrrr/main.go index ff48845..0d92081 100644 --- a/cmd/smtp2shoutrrr/main.go +++ b/cmd/smtp2shoutrrr/main.go @@ -9,6 +9,8 @@ import ( "git.nakama.town/fmartingr/gotoolkit/model" "git.nakama.town/fmartingr/gotoolkit/service" "git.nakama.town/fmartingr/smtp2shoutrrr" + + _ "golang.org/x/crypto/x509roots/fallback" ) func main() { diff --git a/go.mod b/go.mod index a1ed44d..992c159 100644 --- a/go.mod +++ b/go.mod @@ -7,6 +7,7 @@ require ( github.com/containrrr/shoutrrr v0.8.0 github.com/emersion/go-sasl v0.0.0-20200509203442-7bfe0ed36a21 github.com/emersion/go-smtp v0.21.3 + golang.org/x/crypto/x509roots/fallback v0.0.0-20250118192723-a8ea4be81f07 ) require ( diff --git a/go.sum b/go.sum index 49bbf13..889b388 100644 --- a/go.sum +++ b/go.sum @@ -37,6 +37,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +golang.org/x/crypto/x509roots/fallback v0.0.0-20250118192723-a8ea4be81f07 h1:Tuk3hxOkRoX4Xwph6/tRU1wGumEsVYM2TZfvAC6MllM= +golang.org/x/crypto/x509roots/fallback v0.0.0-20250118192723-a8ea4be81f07/go.mod h1:kNa9WdvYnzFwC79zRpLRMJbdEFlhyM5RPFBBZp/wWH8= golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= From 304e343a655bdf39dd51ba41e88d1131192f6f35 Mon Sep 17 00:00:00 2001 From: "Felipe M." Date: Fri, 21 Feb 2025 07:52:59 +0100 Subject: [PATCH 12/20] deps: go-toolkit to v0.1.0 --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 992c159..1be122a 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module git.nakama.town/fmartingr/smtp2shoutrrr go 1.23.3 require ( - git.nakama.town/fmartingr/gotoolkit v0.0.0-20241123184121-ef80892aa542 + git.nakama.town/fmartingr/gotoolkit v0.1.0 github.com/containrrr/shoutrrr v0.8.0 github.com/emersion/go-sasl v0.0.0-20200509203442-7bfe0ed36a21 github.com/emersion/go-smtp v0.21.3 diff --git a/go.sum b/go.sum index 889b388..7880fd7 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -git.nakama.town/fmartingr/gotoolkit v0.0.0-20241123184121-ef80892aa542 h1:y1LuMKkVUvrPDOuHmhHTGpNFu+S34NwxgAU3cHN/ihk= -git.nakama.town/fmartingr/gotoolkit v0.0.0-20241123184121-ef80892aa542/go.mod h1:wT4a0weU051koADRquRKWQeUsNeOyLDm7lqSqVl16Z8= +git.nakama.town/fmartingr/gotoolkit v0.1.0 h1:qZcoF+L/x5dTyhBSmo3siEYTy2Vlnlu1R6OvdF7jFsY= +git.nakama.town/fmartingr/gotoolkit v0.1.0/go.mod h1:wT4a0weU051koADRquRKWQeUsNeOyLDm7lqSqVl16Z8= github.com/containrrr/shoutrrr v0.8.0 h1:mfG2ATzIS7NR2Ec6XL+xyoHzN97H8WPjir8aYzJUSec= github.com/containrrr/shoutrrr v0.8.0/go.mod h1:ioyQAyu1LJY6sILuNyKaQaw+9Ttik5QePU8atnAdO2o= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= From b20d2d9735102ffd086105835aad298e5bba4164 Mon Sep 17 00:00:00 2001 From: "Felipe M." Date: Fri, 21 Feb 2025 07:53:52 +0100 Subject: [PATCH 13/20] ci: added forgejo action for codeberg.org --- .forgejo/workflows/release.yml | 38 ++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .forgejo/workflows/release.yml diff --git a/.forgejo/workflows/release.yml b/.forgejo/workflows/release.yml new file mode 100644 index 0000000..cef5f1e --- /dev/null +++ b/.forgejo/workflows/release.yml @@ -0,0 +1,38 @@ +name: Release + +on: + push: + tags: + - 'v*' + branches: + - main + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up Docker + uses: actions/setup-docker@v3 + + - name: Docker Login + env: + GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} + run: | + docker login -u fmartingr -p $GITEA_TOKEN codeberg.org + + - name: Set up Go + uses: actions/setup-go@v4 + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v4 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + distribution: goreleaser + version: latest + args: release --clean From 361175d6afe115b9319d7de079750a45026232b5 Mon Sep 17 00:00:00 2001 From: "Felipe M." Date: Fri, 21 Feb 2025 07:58:08 +0100 Subject: [PATCH 14/20] chore: ignore .DS_Store files --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 7a7ec77..7f14e85 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,4 @@ dist/ # smtp2shoutrrr config.toml .aider* +.DS_Store From a15223a5c2279e718abd6f1bd6f474b7e3a6ff8c Mon Sep 17 00:00:00 2001 From: "Felipe M." Date: Fri, 21 Feb 2025 08:14:39 +0100 Subject: [PATCH 15/20] refactor: change base url to codeberg.org --- .goreleaser.yml | 16 ++++++++-------- Makefile | 2 +- README.md | 8 ++++---- cmd/sendmail/main.go | 2 +- cmd/smtp2shoutrrr/main.go | 2 +- go.mod | 4 +--- 6 files changed, 16 insertions(+), 18 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index 1d3c91c..65309fd 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,8 +1,8 @@ version: 2 gitea_urls: - api: https://git.nakama.town/api/v1 - download: https://git.nakama.town + api: https://codeberg.org/api/v1 + download: https://codeberg.org before: hooks: @@ -51,7 +51,7 @@ archives: dockers: - image_templates: - - &amd64_image "git.nakama.town/fmartingr/smtp2shoutrrr:{{ .Version }}-amd64" + - &amd64_image "codeberg.org/fmartingr/smtp2shoutrrr:{{ .Version }}-amd64" use: buildx dockerfile: &dockerfile Containerfile goos: linux @@ -60,7 +60,7 @@ dockers: - "--pull" - "--platform=linux/amd64" - image_templates: - - &arm64_image "git.nakama.town/fmartingr/smtp2shoutrrr:{{ .Version }}-arm64" + - &arm64_image "codeberg.org/fmartingr/smtp2shoutrrr:{{ .Version }}-arm64" use: buildx dockerfile: *dockerfile goos: linux @@ -69,7 +69,7 @@ dockers: - "--pull" - "--platform=linux/arm64" - image_templates: - - &armv7_image "git.nakama.town/fmartingr/smtp2shoutrrr:{{ .Version }}-armv7" + - &armv7_image "codeberg.org/fmartingr/smtp2shoutrrr:{{ .Version }}-armv7" use: buildx dockerfile: *dockerfile goos: linux @@ -80,12 +80,12 @@ dockers: - "--platform=linux/arm/v7" docker_manifests: - - name_template: "git.nakama.town/fmartingr/smtp2shoutrrr:{{ .Version }}" + - name_template: "codeberg.org/fmartingr/smtp2shoutrrr:{{ .Version }}" image_templates: - *amd64_image - *arm64_image - *armv7_image - # - name_template: "git.nakama.town/fmartingr/smtp2shoutrrr:latest" + # - name_template: "codeberg.org/fmartingr/smtp2shoutrrr:latest" # image_templates: # - *amd64_image # - *arm64_image @@ -94,7 +94,7 @@ docker_manifests: nfpms: - maintainer: Felipe Martin description: SMTP server to forward messages to shoutrrr endpoints - homepage: https://git.nakama.town/fmartingr/smtp2shoutrrr + homepage: https://codeberg.org/fmartingr/smtp2shoutrrr license: AGPL-3.0 formats: - deb diff --git a/Makefile b/Makefile index 90d86e1..290c9e5 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ FROM_MAKEFILE := y CONTAINERFILE_NAME := Containerfile CONTAINER_ALPINE_VERSION := 3.20 -CONTAINER_SOURCE_URL := "https://git.nakama.town/fmartingr/${PROJECT_NAME}" +CONTAINER_SOURCE_URL := "https://codeberg.org/fmartingr/${PROJECT_NAME}" CONTAINER_MAINTAINER := "Felipe Martin " CONTAINER_BIN_NAME := ${PROJECT_NAME} diff --git a/README.md b/README.md index 76c1bcb..c881c4c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# smtp2Shoutrrr +# smtp2shoutrrr A simple SMTP server that forwards incoming emails to a [Shoutrrr supported service](https://containrrr.dev/shoutrrr/). @@ -33,13 +33,13 @@ Target = "ntfy://ntfy.sh/catch-all-topic?tags=unmatched" ### From releases -- Grab the latest release from the [releases page](https://git.nakama.town/fmartingr/smtp2shoutrrr/releases) +- Grab the latest release from the [releases page](https://codeberg.org/fmartingr/smtp2shoutrrr/releases) - Put the configuration file in the same directory as the binary - Run the binary for your appropriate platform ### From source (development) -- Clone [this repository](https://git.nakama.town/fmartingr/smtp2shoutrrr) +- Clone [this repository](https://codeberg.org/fmartingr/smtp2shoutrrr) - Put the configuration file in the repository folder - Run `make quick-run` @@ -51,7 +51,7 @@ Target = "ntfy://ntfy.sh/catch-all-topic?tags=unmatched" ```bash docker run -v /path/to/config.toml:/config.toml \ -p 11025:11025 \ - git.nakama.town/fmartingr/smtp2shoutrrr:latest + codeberg.org/fmartingr/smtp2shoutrrr:latest ``` ## Development diff --git a/cmd/sendmail/main.go b/cmd/sendmail/main.go index df894b3..dfab1c1 100644 --- a/cmd/sendmail/main.go +++ b/cmd/sendmail/main.go @@ -10,7 +10,7 @@ import ( "git.nakama.town/fmartingr/gotoolkit/encoding" "github.com/emersion/go-sasl" - "git.nakama.town/fmartingr/smtp2shoutrrr" + "codeberg.org/fmartingr/smtp2shoutrrr" ) // The ANONYMOUS mechanism name. diff --git a/cmd/smtp2shoutrrr/main.go b/cmd/smtp2shoutrrr/main.go index 0d92081..60fe9b5 100644 --- a/cmd/smtp2shoutrrr/main.go +++ b/cmd/smtp2shoutrrr/main.go @@ -5,10 +5,10 @@ import ( "log/slog" "os" + "codeberg.org/fmartingr/smtp2shoutrrr" "git.nakama.town/fmartingr/gotoolkit/encoding" "git.nakama.town/fmartingr/gotoolkit/model" "git.nakama.town/fmartingr/gotoolkit/service" - "git.nakama.town/fmartingr/smtp2shoutrrr" _ "golang.org/x/crypto/x509roots/fallback" ) diff --git a/go.mod b/go.mod index 1be122a..e5c8462 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module git.nakama.town/fmartingr/smtp2shoutrrr +module codeberg.org/fmartingr/smtp2shoutrrr go 1.23.3 @@ -17,5 +17,3 @@ require ( github.com/pelletier/go-toml/v2 v2.2.3 // indirect golang.org/x/sys v0.22.0 // indirect ) - -//replace git.nakama.town/fmartingr/gotoolkit => ../gotoolkit From 8a684e9ec1d029b5df05ef2e07762a9c372eb417 Mon Sep 17 00:00:00 2001 From: "Felipe M." Date: Fri, 21 Feb 2025 09:59:12 +0100 Subject: [PATCH 16/20] test: added some tests --- backend.go | 1 - backend_test.go | 85 +++++++++++++++++++++++++++++++++++++++++++++++++ go.mod | 23 ++++++++++--- go.sum | 60 ++++++++++++++++++++++++---------- server.go | 1 - 5 files changed, 147 insertions(+), 23 deletions(-) create mode 100644 backend_test.go diff --git a/backend.go b/backend.go index baba722..fd2c379 100644 --- a/backend.go +++ b/backend.go @@ -85,7 +85,6 @@ func (bkd *Backend) forwardEmail(email ReceivedEmail) error { type Session struct { addresses []string - body string config *Config diff --git a/backend_test.go b/backend_test.go new file mode 100644 index 0000000..27e59b1 --- /dev/null +++ b/backend_test.go @@ -0,0 +1,85 @@ +package smtp2shoutrrr + +import ( + "context" + "fmt" + "io" + "net/http" + "net/http/httptest" + "net/smtp" + "testing" + "time" + + "github.com/stretchr/testify/require" +) + +func TestEmailForwarding(t *testing.T) { + // Start mock ntfy server + notifications := make([]string, 0) + mockServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.Method != http.MethodPost { + w.WriteHeader(http.StatusMethodNotAllowed) + return + } + + // Read body and log + body, err := io.ReadAll(r.Body) + if err != nil { + w.WriteHeader(http.StatusInternalServerError) + return + } + + notifications = append(notifications, string(body)) + w.WriteHeader(http.StatusOK) + })) + defer mockServer.Close() + + // Configure the SMTP server + config := &Config{ + Port: 2525, + Username: "testuser", + Password: "testpass", + Recipients: []ConfigRecipient{ + { + Addresses: []string{"test@example.com"}, + Target: "generic+" + mockServer.URL + "/?template=json", + }, + }, + } + + ctx := context.Background() + smtpServer := NewSMTPServer(config) + + // Start the server + go func() { + if err := smtpServer.Start(ctx); err != nil { + t.Errorf("failed to start server: %v", err) + } + }() + + // Give the server time to start + time.Sleep(100 * time.Millisecond) + defer func() { + if err := smtpServer.Stop(ctx); err != nil { + t.Errorf("failed to stop server: %v", err) + } + }() + + // Send test email + auth := smtp.PlainAuth("", config.Username, config.Password, "localhost") + err := smtp.SendMail( + fmt.Sprintf("localhost:%d", config.Port), + auth, + "sender@example.com", + []string{"test@example.com"}, + []byte("Subject: Test Email\r\n\r\nThis is a test email body"), + ) + require.NoError(t, err) + + // Give some time for the notification to be processed + time.Sleep(100 * time.Millisecond) + + // Verify the notification was received + require.Len(t, notifications, 1) + require.Contains(t, notifications[0], "This is a test email body") +} diff --git a/go.mod b/go.mod index e5c8462..1e6bd9e 100644 --- a/go.mod +++ b/go.mod @@ -5,15 +5,28 @@ go 1.23.3 require ( git.nakama.town/fmartingr/gotoolkit v0.1.0 github.com/containrrr/shoutrrr v0.8.0 - github.com/emersion/go-sasl v0.0.0-20200509203442-7bfe0ed36a21 + github.com/emersion/go-sasl v0.0.0-20241020182733-b788ff22d5a6 github.com/emersion/go-smtp v0.21.3 - golang.org/x/crypto/x509roots/fallback v0.0.0-20250118192723-a8ea4be81f07 + github.com/stretchr/testify v1.9.0 + golang.org/x/crypto/x509roots/fallback v0.0.0-20250214233241-911360c8a4f4 ) require ( - github.com/fatih/color v1.15.0 // indirect - github.com/mattn/go-colorable v0.1.13 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/fatih/color v1.18.0 // indirect + github.com/go-logr/logr v1.4.1 // indirect + github.com/golang/protobuf v1.5.4 // indirect + github.com/google/go-cmp v0.6.0 // indirect + github.com/kr/pretty v0.3.0 // indirect + github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/pelletier/go-toml/v2 v2.2.3 // indirect - golang.org/x/sys v0.22.0 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/rogpeppe/go-internal v1.8.1 // indirect + golang.org/x/net v0.25.0 // indirect + golang.org/x/sys v0.30.0 // indirect + golang.org/x/text v0.21.0 // indirect + golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect + gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 7880fd7..c0021c5 100644 --- a/go.sum +++ b/go.sum @@ -2,28 +2,43 @@ git.nakama.town/fmartingr/gotoolkit v0.1.0 h1:qZcoF+L/x5dTyhBSmo3siEYTy2Vlnlu1R6 git.nakama.town/fmartingr/gotoolkit v0.1.0/go.mod h1:wT4a0weU051koADRquRKWQeUsNeOyLDm7lqSqVl16Z8= github.com/containrrr/shoutrrr v0.8.0 h1:mfG2ATzIS7NR2Ec6XL+xyoHzN97H8WPjir8aYzJUSec= github.com/containrrr/shoutrrr v0.8.0/go.mod h1:ioyQAyu1LJY6sILuNyKaQaw+9Ttik5QePU8atnAdO2o= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/emersion/go-sasl v0.0.0-20200509203442-7bfe0ed36a21 h1:OJyUGMJTzHTd1XQp98QTaHernxMYzRaOasRir9hUlFQ= github.com/emersion/go-sasl v0.0.0-20200509203442-7bfe0ed36a21/go.mod h1:iL2twTeMvZnrg54ZoPDNfJaJaqy0xIQFuBdrLsmspwQ= +github.com/emersion/go-sasl v0.0.0-20241020182733-b788ff22d5a6 h1:oP4q0fw+fOSWn3DfFi4EXdT+B+gTtzx8GC9xsc26Znk= +github.com/emersion/go-sasl v0.0.0-20241020182733-b788ff22d5a6/go.mod h1:iL2twTeMvZnrg54ZoPDNfJaJaqy0xIQFuBdrLsmspwQ= github.com/emersion/go-smtp v0.21.3 h1:7uVwagE8iPYE48WhNsng3RRpCUpFvNl39JGNSIyGVMY= github.com/emersion/go-smtp v0.21.3/go.mod h1:qm27SGYgoIPRot6ubfQ/GpiPy/g3PaZAVRxiO/sDUgQ= github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= -github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= -github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= +github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= +github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= +github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 h1:yAJXTCF9TqKcTiHJAE8dj7HMvPfh66eeA2JYW7eFpSE= github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/jarcoal/httpmock v1.3.0 h1:2RJ8GP0IIaWwcC9Fp2BmVi8Kog3v2Hn7VXM3fTd+nuc= github.com/jarcoal/httpmock v1.3.0/go.mod h1:3yb8rc4BI7TCBhFY8ng0gjuLKJNquuDNiPaZjnENuYg= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= +github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= @@ -33,23 +48,36 @@ github.com/onsi/gomega v1.27.6 h1:ENqfyGeS5AX/rlXDd/ETokDz93u0YufY1Pgxuy/PvWE= github.com/onsi/gomega v1.27.6/go.mod h1:PIQNjfQwkP3aQAH7lf7j87O/5FiNr+ZR8+ipb+qQlhg= github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M= github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= +github.com/rogpeppe/go-internal v1.8.1 h1:geMPLpDpQOgVyCg5z5GoRwLHepNdb71NXb67XFkP+Eg= +github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= golang.org/x/crypto/x509roots/fallback v0.0.0-20250118192723-a8ea4be81f07 h1:Tuk3hxOkRoX4Xwph6/tRU1wGumEsVYM2TZfvAC6MllM= golang.org/x/crypto/x509roots/fallback v0.0.0-20250118192723-a8ea4be81f07/go.mod h1:kNa9WdvYnzFwC79zRpLRMJbdEFlhyM5RPFBBZp/wWH8= -golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= -golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= +golang.org/x/crypto/x509roots/fallback v0.0.0-20250214233241-911360c8a4f4 h1:QDiVWrFJ2lyXzr3pJnIREQWR8S7jkjzuWJPJda8Ic8E= +golang.org/x/crypto/x509roots/fallback v0.0.0-20250214233241-911360c8a4f4/go.mod h1:lxN5T34bK4Z/i6cMaU7frUU57VkDXFD4Kamfl/cp9oU= +golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= +golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= -golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= -golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/tools v0.7.0 h1:W4OVu8VVOaIO0yzWMNdepAulS7YfoS3Zabrm8DOXXU4= -golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s= -google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= +golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/server.go b/server.go index afaa4a7..7262576 100644 --- a/server.go +++ b/server.go @@ -14,7 +14,6 @@ var _ model.Server = (*smtpServer)(nil) type smtpServer struct { backend *smtp.Server - config Config } func (s *smtpServer) IsEnabled() bool { From ba23c2816cbbd41719286e317e1bc500a16f92f2 Mon Sep 17 00:00:00 2001 From: "Felipe M." Date: Fri, 21 Feb 2025 09:59:45 +0100 Subject: [PATCH 17/20] deps: upgrade go 1.24 --- go.mod | 2 +- go.sum | 11 ----------- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/go.mod b/go.mod index 1e6bd9e..34613c8 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module codeberg.org/fmartingr/smtp2shoutrrr -go 1.23.3 +go 1.24 require ( git.nakama.town/fmartingr/gotoolkit v0.1.0 diff --git a/go.sum b/go.sum index c0021c5..3d41520 100644 --- a/go.sum +++ b/go.sum @@ -5,14 +5,11 @@ github.com/containrrr/shoutrrr v0.8.0/go.mod h1:ioyQAyu1LJY6sILuNyKaQaw+9Ttik5Qe github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/emersion/go-sasl v0.0.0-20200509203442-7bfe0ed36a21 h1:OJyUGMJTzHTd1XQp98QTaHernxMYzRaOasRir9hUlFQ= github.com/emersion/go-sasl v0.0.0-20200509203442-7bfe0ed36a21/go.mod h1:iL2twTeMvZnrg54ZoPDNfJaJaqy0xIQFuBdrLsmspwQ= github.com/emersion/go-sasl v0.0.0-20241020182733-b788ff22d5a6 h1:oP4q0fw+fOSWn3DfFi4EXdT+B+gTtzx8GC9xsc26Znk= github.com/emersion/go-sasl v0.0.0-20241020182733-b788ff22d5a6/go.mod h1:iL2twTeMvZnrg54ZoPDNfJaJaqy0xIQFuBdrLsmspwQ= github.com/emersion/go-smtp v0.21.3 h1:7uVwagE8iPYE48WhNsng3RRpCUpFvNl39JGNSIyGVMY= github.com/emersion/go-smtp v0.21.3/go.mod h1:qm27SGYgoIPRot6ubfQ/GpiPy/g3PaZAVRxiO/sDUgQ= -github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= -github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= @@ -35,11 +32,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= -github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= -github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/onsi/ginkgo/v2 v2.9.2 h1:BA2GMJOtfGAfagzYtrAlufIP0lq6QERkFmHLMLPwFSU= @@ -56,16 +50,11 @@ github.com/rogpeppe/go-internal v1.8.1 h1:geMPLpDpQOgVyCg5z5GoRwLHepNdb71NXb67XF github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -golang.org/x/crypto/x509roots/fallback v0.0.0-20250118192723-a8ea4be81f07 h1:Tuk3hxOkRoX4Xwph6/tRU1wGumEsVYM2TZfvAC6MllM= -golang.org/x/crypto/x509roots/fallback v0.0.0-20250118192723-a8ea4be81f07/go.mod h1:kNa9WdvYnzFwC79zRpLRMJbdEFlhyM5RPFBBZp/wWH8= golang.org/x/crypto/x509roots/fallback v0.0.0-20250214233241-911360c8a4f4 h1:QDiVWrFJ2lyXzr3pJnIREQWR8S7jkjzuWJPJda8Ic8E= golang.org/x/crypto/x509roots/fallback v0.0.0-20250214233241-911360c8a4f4/go.mod h1:lxN5T34bK4Z/i6cMaU7frUU57VkDXFD4Kamfl/cp9oU= golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= -golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= -golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= From 7c588033c9474d4111c6f7bcc4cf2eb5c0290c5a Mon Sep 17 00:00:00 2001 From: "Felipe M." Date: Fri, 21 Feb 2025 09:59:59 +0100 Subject: [PATCH 18/20] ci: makefile commands to test, lint and format --- .forgejo/workflows/ci.yml | 31 +++++++++++++++++++++++++++++++ .woodpecker/ci.yml | 23 +++++++++++++++++++++++ Makefile | 16 +++++++++++++--- 3 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 .forgejo/workflows/ci.yml create mode 100644 .woodpecker/ci.yml diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml new file mode 100644 index 0000000..9f233b8 --- /dev/null +++ b/.forgejo/workflows/ci.yml @@ -0,0 +1,31 @@ +name: CI +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: "1.24" + + - name: Format + run: | + make format + git diff --exit-code + + - name: Lint + uses: golangci/golangci-lint-action@v4 + with: + version: v1.56 + args: --timeout=5m + + - name: Test + run: make test diff --git a/.woodpecker/ci.yml b/.woodpecker/ci.yml new file mode 100644 index 0000000..4353088 --- /dev/null +++ b/.woodpecker/ci.yml @@ -0,0 +1,23 @@ +when: + event: + - push + - pull_request + branch: + - main + +steps: + format: + image: golang:1.24 + commands: + - make format + - git diff --exit-code # Fail if files were changed + + lint: + image: golang:1.24 + commands: + - make ci-lint + + test: + image: golang:1.24 + commands: + - make test diff --git a/Makefile b/Makefile index 290c9e5..0951519 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,8 @@ SOURCE_FILES ?=./... TEST_OPTIONS ?= -v -failfast -race -bench=. -benchtime=100000x -cover -coverprofile=coverage.out TEST_TIMEOUT ?=1m +GOLANGCI_LINT_VERSION ?= v1.64.5 + CLEAN_OPTIONS ?=-modcache -testcache CGO_ENABLED := 0 @@ -78,13 +80,21 @@ run: ### Executes the project build locally .PHONY: format format: ### Executes the formatting pipeline on the project $(info: Make: Format) - @bash scripts/format.sh + @go fmt ./... + @go mod tidy + +.PHONY: ci-lint +ci-lint: ### Check the project for errors + $(info: Make: Lint) + @go install github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINT_VERSION} + @golangci-lint run ./... .PHONY: lint lint: ### Check the project for errors $(info: Make: Lint) - @bash scripts/lint.sh + @golangci-lint run ./... .PHONY: test test: ### Runs the test suite - @bash scripts/test.sh + $(info: Make: Test) + CGO_ENABLED=1 go test ${TEST_OPTIONS} -timeout=${TEST_TIMEOUT} ${SOURCE_FILES} From 98f7448d49894b74fae58b4f2c35520a1cbbc479 Mon Sep 17 00:00:00 2001 From: "Felipe M." Date: Wed, 26 Mar 2025 17:37:13 +0100 Subject: [PATCH 19/20] Revert "refactor: change base url to codeberg.org" This reverts commit a15223a5c2279e718abd6f1bd6f474b7e3a6ff8c. --- .goreleaser.yml | 16 ++++++++-------- Makefile | 2 +- README.md | 8 ++++---- cmd/sendmail/main.go | 2 +- cmd/smtp2shoutrrr/main.go | 2 +- go.mod | 4 +++- 6 files changed, 18 insertions(+), 16 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index 65309fd..1d3c91c 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,8 +1,8 @@ version: 2 gitea_urls: - api: https://codeberg.org/api/v1 - download: https://codeberg.org + api: https://git.nakama.town/api/v1 + download: https://git.nakama.town before: hooks: @@ -51,7 +51,7 @@ archives: dockers: - image_templates: - - &amd64_image "codeberg.org/fmartingr/smtp2shoutrrr:{{ .Version }}-amd64" + - &amd64_image "git.nakama.town/fmartingr/smtp2shoutrrr:{{ .Version }}-amd64" use: buildx dockerfile: &dockerfile Containerfile goos: linux @@ -60,7 +60,7 @@ dockers: - "--pull" - "--platform=linux/amd64" - image_templates: - - &arm64_image "codeberg.org/fmartingr/smtp2shoutrrr:{{ .Version }}-arm64" + - &arm64_image "git.nakama.town/fmartingr/smtp2shoutrrr:{{ .Version }}-arm64" use: buildx dockerfile: *dockerfile goos: linux @@ -69,7 +69,7 @@ dockers: - "--pull" - "--platform=linux/arm64" - image_templates: - - &armv7_image "codeberg.org/fmartingr/smtp2shoutrrr:{{ .Version }}-armv7" + - &armv7_image "git.nakama.town/fmartingr/smtp2shoutrrr:{{ .Version }}-armv7" use: buildx dockerfile: *dockerfile goos: linux @@ -80,12 +80,12 @@ dockers: - "--platform=linux/arm/v7" docker_manifests: - - name_template: "codeberg.org/fmartingr/smtp2shoutrrr:{{ .Version }}" + - name_template: "git.nakama.town/fmartingr/smtp2shoutrrr:{{ .Version }}" image_templates: - *amd64_image - *arm64_image - *armv7_image - # - name_template: "codeberg.org/fmartingr/smtp2shoutrrr:latest" + # - name_template: "git.nakama.town/fmartingr/smtp2shoutrrr:latest" # image_templates: # - *amd64_image # - *arm64_image @@ -94,7 +94,7 @@ docker_manifests: nfpms: - maintainer: Felipe Martin description: SMTP server to forward messages to shoutrrr endpoints - homepage: https://codeberg.org/fmartingr/smtp2shoutrrr + homepage: https://git.nakama.town/fmartingr/smtp2shoutrrr license: AGPL-3.0 formats: - deb diff --git a/Makefile b/Makefile index 0951519..e9fe7e3 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ FROM_MAKEFILE := y CONTAINERFILE_NAME := Containerfile CONTAINER_ALPINE_VERSION := 3.20 -CONTAINER_SOURCE_URL := "https://codeberg.org/fmartingr/${PROJECT_NAME}" +CONTAINER_SOURCE_URL := "https://git.nakama.town/fmartingr/${PROJECT_NAME}" CONTAINER_MAINTAINER := "Felipe Martin " CONTAINER_BIN_NAME := ${PROJECT_NAME} diff --git a/README.md b/README.md index c881c4c..76c1bcb 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# smtp2shoutrrr +# smtp2Shoutrrr A simple SMTP server that forwards incoming emails to a [Shoutrrr supported service](https://containrrr.dev/shoutrrr/). @@ -33,13 +33,13 @@ Target = "ntfy://ntfy.sh/catch-all-topic?tags=unmatched" ### From releases -- Grab the latest release from the [releases page](https://codeberg.org/fmartingr/smtp2shoutrrr/releases) +- Grab the latest release from the [releases page](https://git.nakama.town/fmartingr/smtp2shoutrrr/releases) - Put the configuration file in the same directory as the binary - Run the binary for your appropriate platform ### From source (development) -- Clone [this repository](https://codeberg.org/fmartingr/smtp2shoutrrr) +- Clone [this repository](https://git.nakama.town/fmartingr/smtp2shoutrrr) - Put the configuration file in the repository folder - Run `make quick-run` @@ -51,7 +51,7 @@ Target = "ntfy://ntfy.sh/catch-all-topic?tags=unmatched" ```bash docker run -v /path/to/config.toml:/config.toml \ -p 11025:11025 \ - codeberg.org/fmartingr/smtp2shoutrrr:latest + git.nakama.town/fmartingr/smtp2shoutrrr:latest ``` ## Development diff --git a/cmd/sendmail/main.go b/cmd/sendmail/main.go index dfab1c1..df894b3 100644 --- a/cmd/sendmail/main.go +++ b/cmd/sendmail/main.go @@ -10,7 +10,7 @@ import ( "git.nakama.town/fmartingr/gotoolkit/encoding" "github.com/emersion/go-sasl" - "codeberg.org/fmartingr/smtp2shoutrrr" + "git.nakama.town/fmartingr/smtp2shoutrrr" ) // The ANONYMOUS mechanism name. diff --git a/cmd/smtp2shoutrrr/main.go b/cmd/smtp2shoutrrr/main.go index 60fe9b5..0d92081 100644 --- a/cmd/smtp2shoutrrr/main.go +++ b/cmd/smtp2shoutrrr/main.go @@ -5,10 +5,10 @@ import ( "log/slog" "os" - "codeberg.org/fmartingr/smtp2shoutrrr" "git.nakama.town/fmartingr/gotoolkit/encoding" "git.nakama.town/fmartingr/gotoolkit/model" "git.nakama.town/fmartingr/gotoolkit/service" + "git.nakama.town/fmartingr/smtp2shoutrrr" _ "golang.org/x/crypto/x509roots/fallback" ) diff --git a/go.mod b/go.mod index 34613c8..31d8d3a 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module codeberg.org/fmartingr/smtp2shoutrrr +module git.nakama.town/fmartingr/smtp2shoutrrr go 1.24 @@ -30,3 +30,5 @@ require ( gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) + +//replace git.nakama.town/fmartingr/gotoolkit => ../gotoolkit From 103742ed350f226f11d55af47b3445050f71bd30 Mon Sep 17 00:00:00 2001 From: "Felipe M." Date: Wed, 26 Mar 2025 17:37:58 +0100 Subject: [PATCH 20/20] chore: remove forgejo workflows --- .forgejo/workflows/ci.yml | 31 --------------------------- .forgejo/workflows/release.yml | 38 ---------------------------------- 2 files changed, 69 deletions(-) delete mode 100644 .forgejo/workflows/ci.yml delete mode 100644 .forgejo/workflows/release.yml diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml deleted file mode 100644 index 9f233b8..0000000 --- a/.forgejo/workflows/ci.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: CI -on: - push: - branches: [main] - pull_request: - branches: [main] - -jobs: - test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: "1.24" - - - name: Format - run: | - make format - git diff --exit-code - - - name: Lint - uses: golangci/golangci-lint-action@v4 - with: - version: v1.56 - args: --timeout=5m - - - name: Test - run: make test diff --git a/.forgejo/workflows/release.yml b/.forgejo/workflows/release.yml deleted file mode 100644 index cef5f1e..0000000 --- a/.forgejo/workflows/release.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: Release - -on: - push: - tags: - - 'v*' - branches: - - main - -jobs: - release: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Set up Docker - uses: actions/setup-docker@v3 - - - name: Docker Login - env: - GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} - run: | - docker login -u fmartingr -p $GITEA_TOKEN codeberg.org - - - name: Set up Go - uses: actions/setup-go@v4 - - - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v4 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - distribution: goreleaser - version: latest - args: release --clean