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

Adjust the Display Name of the mailbox

lotk0eb24fbd86e4
diff --git a/core/api/mail_boxes/v1/mailboxes.go b/core/api/mail_boxes/v1/mailboxes.go
index 7689959d..23d61085 100644
--- a/core/api/mail_boxes/v1/mailboxes.go
+++ b/core/api/mail_boxes/v1/mailboxes.go
@@ -25,7 +25,7 @@ type AddMailboxReq struct {
g.Meta `path:"/mailbox/create" tags:"MailBox" method:"post" summary:"Create mailbox" in:"body"`
Authorization string `json:"authorization" dc:"Authorization" in:"header"`
Domain string `json:"domain" v:"required|domain" dc:"Domain"`
- FullName string `json:"full_name" v:"required|min-length:1" dc:"username"`
+ FullName string `json:"full_name" v:"min-length:1" dc:"username"`
LocalPart string `json:"local_part" v:"required|min-length:1|regex:[\\w-]{1,}" dc:"local_part"`
Password string `json:"password" v:"required|min-length:8" dc:"Password"`
Active int `json:"active" v:"required" dc:"Status" d:"1"`
@@ -55,7 +55,7 @@ type UpdateMailboxReq struct {
g.Meta `path:"/mailbox/update" tags:"MailBox" method:"post" summary:"Update mailbox" in:"body"`
Authorization string `json:"authorization" dc:"Authorization" in:"header"`
Domain string `json:"domain" v:"required|domain" dc:"Domain"`
- FullName string `json:"full_name" v:"required|min-length:1" dc:"username"`
+ FullName string `json:"full_name" v:"min-length:1" dc:"username"`
LocalPart string `json:"local_part" v:"required|min-length:1|regex:[\\w-]{1,}" dc:"local_part"`
Password string `json:"password" v:"required|min-length:8" dc:"Password"`
Active int `json:"active" v:"required" dc:"Status" d:"1"`
diff --git a/core/internal/controller/mail_boxes/mail_boxes_v1_add_mailbox.go b/core/internal/controller/mail_boxes/mail_boxes_v1_add_mailbox.go
index 44b999b7..0b7c14d7 100644
--- a/core/internal/controller/mail_boxes/mail_boxes_v1_add_mailbox.go
+++ b/core/internal/controller/mail_boxes/mail_boxes_v1_add_mailbox.go
@@ -23,6 +23,10 @@ func (c *ControllerV1) AddMailbox(ctx context.Context, req *v1.AddMailboxReq) (r
Active: req.Active,
}
+ if mailbox.FullName == "" {
+ mailbox.FullName = req.LocalPart
+ }
+
if err = mail_boxes.Add(ctx, mailbox); err != nil {
return nil, err
}
diff --git a/core/internal/controller/mail_boxes/mail_boxes_v1_update_mailbox.go b/core/internal/controller/mail_boxes/mail_boxes_v1_update_mailbox.go
index 54f04873..34cdf7a4 100644
--- a/core/internal/controller/mail_boxes/mail_boxes_v1_update_mailbox.go
+++ b/core/internal/controller/mail_boxes/mail_boxes_v1_update_mailbox.go
@@ -21,7 +21,9 @@ func (c *ControllerV1) UpdateMailbox(ctx context.Context, req *v1.UpdateMailboxR
Domain: req.Domain,
Active: req.Active,
}
-
+ if mailbox.FullName == "" {
+ mailbox.FullName = req.LocalPart
+ }
if err = mail_boxes.Update(ctx, mailbox); err != nil {
return nil, err
}