Skip to content

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

Optimized Subscription form submit, stored username. Optimized domain creation, automatic create default mailboxes. Change subscription form main theme color to green.

Jackf3adcffbd3eb
diff --git a/core/internal/controller/campaign/campaign_v1_form.go b/core/internal/controller/campaign/campaign_v1_form.go
index 93bf64eb..f9b4bf67 100644
--- a/core/internal/controller/campaign/campaign_v1_form.go
+++ b/core/internal/controller/campaign/campaign_v1_form.go
@@ -18,6 +18,7 @@ func (c *ControllerV1) Form(ctx context.Context, req *v1.FormReq) (res *v1.FormR
// Verify Csrf token if needed
if req.Token == "" {
r.Response.WriteStatus(400, "CSRF token not provided")
+ return
}
var v *g.Var
@@ -45,7 +46,9 @@ func (c *ControllerV1) Form(ctx context.Context, req *v1.FormReq) (res *v1.FormR
GroupId: groupId,
Active: 1,
CreateTime: int(time.Now().Unix()),
- // TODO : Add extra fields if needed
+ Attribs: map[string]string{
+ "Username": req.Name,
+ },
})
}
diff --git a/core/internal/service/domains/domains.go b/core/internal/service/domains/domains.go
index 738d8e7f..f139abb0 100644
--- a/core/internal/service/domains/domains.go
+++ b/core/internal/service/domains/domains.go
@@ -3,12 +3,15 @@ package domains
import (
v2 "billionmail-core/api/dockerapi/v1"
v1 "billionmail-core/api/domains/v1"
+ mail_v1 "billionmail-core/api/mail_boxes/v1"
"billionmail-core/internal/consts"
docker "billionmail-core/internal/service/dockerapi"
+ "billionmail-core/internal/service/mail_boxes"
"billionmail-core/internal/service/mail_service"
"billionmail-core/internal/service/public"
"context"
"fmt"
+ "github.com/gogf/gf/util/grand"
"github.com/gogf/gf/v2/frame/g"
"os"
"path/filepath"
@@ -28,6 +31,22 @@ func Add(ctx context.Context, domain *v1.Domain) error {
_, err := g.DB().Model("domain").Ctx(ctx).Insert(domain)
if err == nil {
+ // Create mailbox abuse, postmaster, admin, noreply, and support for the new domain
+ mailboxes := []string{"abuse", "postmaster", "admin", "noreply", "support"}
+
+ for _, mailbox := range mailboxes {
+ _ = mail_boxes.Add(ctx, &mail_v1.Mailbox{
+ Username: mailbox + "@" + domain.Domain,
+ Password: grand.S(16),
+ FullName: mailbox,
+ IsAdmin: 0,
+ Quota: 5242880,
+ LocalPart: mailbox,
+ Domain: domain.Domain,
+ Active: 1,
+ })
+ }
+
// attempt update hostname in .env file
hostname := public.MustGetDockerEnv("BILLIONMAIL_HOSTNAME", "")
diff --git a/core/template/subscription_form.html b/core/template/subscription_form.html
index e7603530..ef37e5e2 100644
--- a/core/template/subscription_form.html
+++ b/core/template/subscription_form.html
@@ -12,13 +12,12 @@
<!-- Font Awesome -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css" rel="stylesheet">
- <!-- 配置Tailwind自定义颜色和字体 -->
<script>
tailwind.config = {
theme: {
extend: {
colors: {
- primary: '#165DFF',
+ primary: '#20a53a',
secondary: '#36BFFA',
neutral: '#F5F7FA',
dark: '#1D2129',
@@ -31,7 +30,6 @@
}
</script>
- <!-- 自定义工具类 -->
<style type="text/tailwindcss">
@layer utilities {
.content-auto {
@@ -44,6 +42,31 @@
@apply hover:shadow-lg hover:-translate-y-0.5 transition-all duration-300;
}
}
+
+ input[type="checkbox"]:checked {
+ background-color: #20a53a !important;
+ background-image: url("data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M12.207 4.793a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0l-2-2a1 1 0 011.414-1.414L6.5 9.086l4.293-4.293a1 1 0 011.414 0z'/%3e%3c/svg%3e") !important;
+ border-color: #20a53a !important;
+ }
+
+ input[type="checkbox"]:checked:hover,
+ input[type="checkbox"]:checked:focus {
+ background-color: #20a53a !important;
+ border-color: #20a53a !important;
+ }
+
+ input[type="checkbox"]:focus {
+ --tw-ring-color: rgba(32, 165, 58, 0.3) !important;
+ --tw-ring-opacity: 0.3 !important;
+ }
+
+ .focus\:ring-primary:focus {
+ --tw-ring-color: rgba(32, 165, 58, var(--tw-ring-opacity)) !important;
+ }
+
+ .text-primary {
+ color: #20a53a !important;
+ }
</style>
<link rel="icon" href="/favicon.ico?v=bbe064771e" type="image/png" />
@@ -94,6 +117,7 @@
<li class="flex items-center">
<input checked="true" id="l-{{$group.Id}}" type="checkbox" name="group_ids"
value="{{$group.Id}}"
+ style="accent-color: #20a53a;"
class="h-5 w-5 text-primary focus:ring-primary border-gray-300 rounded">
<label for="l-{{$group.Id}}"
class="ml-2 block text-sm text-gray-700 cursor-pointer">
diff --git a/core/template/subscription_success.html b/core/template/subscription_success.html
index 87948888..8d9e0c83 100644
--- a/core/template/subscription_success.html
+++ b/core/template/subscription_success.html
@@ -12,13 +12,12 @@
<!-- Font Awesome -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css" rel="stylesheet">
- <!-- 配置Tailwind自定义颜色和字体 -->
<script>
tailwind.config = {
theme: {
extend: {
colors: {
- primary: '#165DFF',
+ primary: '#20a53a',
secondary: '#36BFFA',
neutral: '#F5F7FA',
dark: '#1D2129',
@@ -32,7 +31,6 @@
}
</script>
- <!-- 自定义工具类 -->
<style type="text/tailwindcss">
@layer utilities {
.content-auto {