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 bugs. use FormatMX() instead hard coding.
Jack4ccd3a2e6830
diff --git a/core/internal/service/domains/ssl.go b/core/internal/service/domains/ssl.goindex 640e74e4..00b2afe9 100644--- a/core/internal/service/domains/ssl.go+++ b/core/internal/service/domains/ssl.go@@ -10,14 +10,11 @@ import ("context""encoding/json""github.com/gogf/gf/v2/frame/g"- "strings""time")// ApplyLetsEncryptCertWithHttp applies for a Let's Encrypt certificate for the given domain.func ApplyLetsEncryptCertWithHttp(ctx context.Context, domain string, accountInfo *model.Account) error {- domain = "mail." + strings.TrimPrefix(domain, "mail.")-// Find the existing certificate for the domainif crt, err := FindSSLByDomain(domain); err == nil && crt != nil {if crt.Status == 1 && crt.EndTime > time.Now().Unix() {@@ -25,7 +22,7 @@ func ApplyLetsEncryptCertWithHttp(ctx context.Context, domain string, accountInf}}- certificate, privateKey, err := acme.ApplySSLWithExistingServer(ctx, []string{domain}, accountInfo.Email, "http", "", nil, public.AbsPath(consts.SSL_PATH))+ certificate, privateKey, err := acme.ApplySSLWithExistingServer(ctx, []string{public.FormatMX(domain)}, accountInfo.Email, "http", "", nil, public.AbsPath(consts.SSL_PATH))if err != nil {return err@@ -44,7 +41,7 @@ func ApplyLetsEncryptCertWithHttp(ctx context.Context, domain string, accountInfnotBefore = certInfo.NotBeforesubject = certInfo.SubjectendTime = certInfo.Endtime- dnsNamesBytes, err := json.Marshal([]string{domain})+ dnsNamesBytes, err := json.Marshal([]string{public.FormatMX(domain)})if err == nil {dnsNames = string(dnsNamesBytes)}@@ -80,7 +77,7 @@ func ApplyLetsEncryptCertWithHttp(ctx context.Context, domain string, accountInf// FindSSLByDomain retrieves the SSL certificate information for a given domain.func FindSSLByDomain(domain string) (crt *entity.Letsencrypt, err error) {- err = g.DB().Model("letsencrypts").Where("dns::jsonb ? $1", "mail."+strings.TrimPrefix(domain, "mail.")).Where("status = 1").Order("endtime desc").Limit(1).Scan(&crt)+ err = g.DB().Model("letsencrypts").Where("dns::jsonb ? $1", public.FormatMX(domain)).Where("status = 1").Order("endtime desc").Limit(1).Scan(&crt)return}@@ -90,7 +87,7 @@ func ApplyCertToService(domain, crtPem, keyPem string) (err error) {defer crt.Close()- err = crt.SetSNI(domain, crtPem, keyPem)+ err = crt.SetSNI(public.FormatMX(domain), crtPem, keyPem)return}diff --git a/core/internal/service/mail_service/certificate.go b/core/internal/service/mail_service/certificate.goindex a42934ec..e80aa9f6 100644--- a/core/internal/service/mail_service/certificate.go+++ b/core/internal/service/mail_service/certificate.go@@ -400,7 +400,7 @@ func (c *Certificate) updateDovecotSNIConfig(domain, certPem, keyPem string) errreturn fmt.Errorf("failed to read dovecot config: %v", err)}- domain = "mail." + strings.TrimPrefix(domain, "mail.")+ domain = public.FormatMX(domain)replaceStr := "\n#DOMAIN_SSL_BEGIN_" + domain +"\nlocal_name " + domain +diff --git a/core/internal/service/public/common.go b/core/internal/service/public/common.goindex ac15a243..0b13dbea 100644--- a/core/internal/service/public/common.go+++ b/core/internal/service/public/common.go@@ -2449,3 +2449,8 @@ func SanitizeUTF8(s string) string {return string(result)}++// FormatMX format the email domain+func FormatMX(domain string) string {+ return "mail." + strings.TrimPrefix(domain, "mail.")+}