支持外发邮件增加List-Unsubscribe标头并升级至V2.11.1

This commit is contained in:
smail 2026-10-17 17:12:42 +08:00
parent bc9828b71e
commit 4286bc532c
3 changed files with 21 additions and 2 deletions

View File

@ -678,6 +678,15 @@ func (e *Email) ForwardBuildBytes(ctx *context.Context, sender *models.User, for
h.Set("In-Reply-To", fmt.Sprintf("<%s>", e.MsgID))
}
unsubDomain := cfg.Domain
if len(cfg.Domains) > 0 && cfg.Domains[0] != "" {
unsubDomain = cfg.Domains[0]
}
if unsubDomain != "" {
h.Set("List-Unsubscribe", fmt.Sprintf("<mailto:unsubscribe@%s>", unsubDomain))
h.Set("List-Unsubscribe-Post", "List-Unsubscribe=One-Click")
}
// Create a new mail writer
mw, err := mail.CreateWriter(&b, h)
if err != nil {
@ -882,6 +891,15 @@ func (e *Email) BuildBytes(ctx *context.Context, dkim bool) ([]byte, error) {
h.SetAddressList("Cc", cc)
}
unsubDomain := cfg.Domain
if len(cfg.Domains) > 0 && cfg.Domains[0] != "" {
unsubDomain = cfg.Domains[0]
}
if unsubDomain != "" {
h.Set("List-Unsubscribe", fmt.Sprintf("<mailto:unsubscribe@%s>", unsubDomain))
h.Set("List-Unsubscribe-Post", "List-Unsubscribe=One-Click")
}
// Create a new mail writer
mw, err := mail.CreateWriter(&b, h)
if err != nil {

View File

@ -219,10 +219,11 @@ func buildCodeMessage(from string, challenge Challenge, code string) []byte {
htmlBody := CodeHTML(challenge, code)
return []byte(fmt.Sprintf(
"From: %s\r\nTo: %s\r\nSubject: %s\r\nMIME-Version: 1.0\r\nContent-Type: multipart/alternative; boundary=\"%s\"\r\n\r\n--%s\r\nContent-Type: text/plain; charset=UTF-8\r\nContent-Transfer-Encoding: 8bit\r\n\r\n%s\r\n--%s\r\nContent-Type: text/html; charset=UTF-8\r\nContent-Transfer-Encoding: 8bit\r\n\r\n%s\r\n--%s--\r\n",
"From: %s\r\nTo: %s\r\nSubject: %s\r\nList-Unsubscribe: <mailto:unsubscribe@%s>\r\nList-Unsubscribe-Post: List-Unsubscribe=One-Click\r\nMIME-Version: 1.0\r\nContent-Type: multipart/alternative; boundary=\"%s\"\r\n\r\n--%s\r\nContent-Type: text/plain; charset=UTF-8\r\nContent-Transfer-Encoding: 8bit\r\n\r\n%s\r\n--%s\r\nContent-Type: text/html; charset=UTF-8\r\nContent-Transfer-Encoding: 8bit\r\n\r\n%s\r\n--%s--\r\n",
from,
challenge.Email,
mime.QEncoding.Encode("UTF-8", title),
strings.TrimSpace(strings.Split(from, "@")[len(strings.Split(from, "@"))-1]),
boundary,
boundary,
text,

View File

@ -57,7 +57,7 @@
<el-icon><Setting /></el-icon>
<span class="settings-label">{{ lang.settings }}</span>
</div>
<span class="app-version-badge">V2.11.0</span>
<span class="app-version-badge">V2.11.1</span>
</button>
</div>
</div>