BillionMail gives you open-source MailServer, NewsLetter, Email Marketing — fully self-hosted, dev-friendly, and free from monthly fees. Join the discord: https://discord.gg/asfXzBUhZr
Fixed public pages being blocked by secure entry subscribing to the submission interface replacing files inside the container
lotk17e6a7dcf081
diff --git a/core/internal/cmd/cmd.go b/core/internal/cmd/cmd.goindex 309c0631..dd4ad542 100644--- a/core/internal/cmd/cmd.go+++ b/core/internal/cmd/cmd.go@@ -134,6 +134,8 @@ var ("/api/unsubscribe": {},"/api/batch_mail/api/send": {},"/api/batch_mail/api/batch_send": {},+ "/api/subscribe/confirm": {},+ "/api/subscribe/submit": {},"/already_subscribed.html": {},"/subscribe_confirm.html": {},"/subscribe_form.html": {},diff --git a/core/internal/controller/middleware/ip_whitelist.go b/core/internal/controller/middleware/ip_whitelist.goindex d58c5b82..26cb5588 100644--- a/core/internal/controller/middleware/ip_whitelist.go+++ b/core/internal/controller/middleware/ip_whitelist.go@@ -18,6 +18,8 @@ var ExcludedPaths = map[string]struct{}{"/api/unsubscribe": {},"/api/batch_mail/api/send": {},"/api/batch_mail/api/batch_send": {},+ "/api/subscribe/submit": {},+ "/api/subscribe/confirm": {},"/already_subscribed.html": {},"/subscribe_confirm.html": {},"/subscribe_form.html": {},diff --git a/core/internal/controller/subscribe_list/subscribe_list.go b/core/internal/controller/subscribe_list/subscribe_list.goindex 00a196df..6ab816a5 100644--- a/core/internal/controller/subscribe_list/subscribe_list.go+++ b/core/internal/controller/subscribe_list/subscribe_list.go@@ -328,8 +328,11 @@ func GetDefaultDomain() (string, error) {func GetSubscribeFormCode(groupToken string) string {filePath := public.AbsPath("../core/public/html/subscribe_form_code.html")content := gfile.GetContents(filePath)+ ctx := context.Background()+ g.Log().Warning(ctx, "subscribe_form_code.html path----->", filePath)if !strings.Contains(content, "{{ SubmitURL . }}") {+ g.Log().Warning(ctx, "subscribe_form_code.html not contains {{ SubmitURL . }}")return ""}diff --git a/core/internal/service/subscribe_list/subscribe_url.go b/core/internal/service/subscribe_list/subscribe_url.godeleted file mode 100644index 9a74f408..00000000--- a/core/internal/service/subscribe_list/subscribe_url.go+++ /dev/null@@ -1,35 +0,0 @@-package subscribe_list--import (- "billionmail-core/internal/service/public"- "context"- "github.com/gogf/gf/v2/frame/g"- "github.com/gogf/gf/v2/os/gfile"- "strings"-)--func ReplaceSubmitUrl(ctx context.Context) {- //hostwork := public.HostWorkDir- //filePath := filepath.Join(hostwork, "/core/public/html/subscribe_form.html")- //content := gfile.GetContents(filePath)-- filePath := public.AbsPath("../core/public/html/subscribe_form_code.html")- content := gfile.GetContents(filePath)-- if !strings.Contains(content, "{{ SubmitURL . }}") {- return- }-- var submitUrl string- hostUrl := public.GethostUrl()- submitUrl = hostUrl + "/api/subscribe/submit"-- newContent := strings.ReplaceAll(content, "{{ SubmitURL . }}", submitUrl)-- err := gfile.PutContents(filePath, newContent)- if err != nil {- g.Log().Errorf(ctx, "Failed to update subscribe form URL: %v", err)-- }--}diff --git a/core/internal/service/timers/timers.go b/core/internal/service/timers/timers.goindex 05756a32..03612978 100644--- a/core/internal/service/timers/timers.go+++ b/core/internal/service/timers/timers.go@@ -9,7 +9,6 @@ import ("billionmail-core/internal/service/mail_service""billionmail-core/internal/service/maillog_stat""billionmail-core/internal/service/relay"- "billionmail-core/internal/service/subscribe_list""billionmail-core/internal/service/warmup""context""github.com/gogf/gf/os/gtimer"@@ -143,11 +142,6 @@ func Start(ctx context.Context) (err error) {// fail2ban access logs detectiongtimer.AddOnce(800*time.Millisecond, fail2ban.NewAccessLogDetection().Start)- // {{ SubmitURL . }}- gtimer.AddOnce(500*time.Millisecond, func() {- subscribe_list.ReplaceSubmitUrl(ctx)- })-g.Log().Debug(ctx, "All timers started successfully")return nil}diff --git a/core/public/html/subscribe_form.html b/core/public/html/subscribe_form.htmlindex 14f3b224..0e91c701 100644--- a/core/public/html/subscribe_form.html+++ b/core/public/html/subscribe_form.html@@ -206,13 +206,15 @@window.onload = function () {var url = new URL(window.location.href);var token = url.searchParams.get('token');+ var hostUrl = url.origin;+ var form = document.getElementById('subscribeForm');+ form.action = hostUrl + "/api/subscribe/submit";if (token) {- // Set hidden fieldvar input = document.createElement('input');input.type = 'hidden';input.name = 'token';input.value = token;- document.getElementById('subscribeForm').appendChild(input);+ form.appendChild(input);}};</script>@@ -220,7 +222,7 @@<body><div class="container"><div class="title">🔔 Join our subscribe</div>- <form id="subscribeForm" method="post" action="{{ SubmitURL . }}">+ <form id="subscribeForm" method="post"><div class="form-group"><div class="input-group"><label for="email">Email Address</label>