From a89d29896459be75c29675c05356e09d6059b6f4 Mon Sep 17 00:00:00 2001 From: "m.huber" Date: Wed, 1 Nov 2023 05:32:21 +0100 Subject: [PATCH 1/3] mailer: add option to set Return-Path --- custom/conf/app.example.ini | 4 ++++ docs/content/administration/config-cheat-sheet.en-us.md | 1 + modules/setting/mailer.go | 1 + services/mailer/mailer.go | 5 ++++- 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index 2209822ff0..3e6d9a3581 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -1578,6 +1578,10 @@ LEVEL = Info ;; Prefix displayed before subject in mail ;SUBJECT_PREFIX = ;; +;; Set the Return-Path header, to let mail clients reply to a different mail as it was send from. +;; If '<>' is set, it indicates has the same efect as if you would set a noreply address for FROM. +;RETURN_PATH = +;; ;; Mail server protocol. One of "smtp", "smtps", "smtp+starttls", "smtp+unix", "sendmail", "dummy". ;; - sendmail: use the operating system's `sendmail` command instead of SMTP. This is common on Linux systems. ;; - dummy: send email messages to the log as a testing phase. diff --git a/docs/content/administration/config-cheat-sheet.en-us.md b/docs/content/administration/config-cheat-sheet.en-us.md index 617715fbaa..e82c4164bc 100644 --- a/docs/content/administration/config-cheat-sheet.en-us.md +++ b/docs/content/administration/config-cheat-sheet.en-us.md @@ -732,6 +732,7 @@ and - `ENABLE_HELO`: **true**: Enable HELO operation. - `HELO_HOSTNAME`: **(retrieved from system)**: HELO hostname. - `FROM`: **_empty_**: Mail from address, RFC 5322. This can be just an email address, or the "Name" \ format. +- `RETURN_PATH`: **_empty_**: Set the Return-Path header, to let mail clients reply to a different mail as it was send from. See [RFC 4021](https://www.rfc-editor.org/rfc/rfc4021#page-17) for more details. - `ENVELOPE_FROM`: **_empty_**: Address set as the From address on the SMTP mail envelope. Set to `<>` to send an empty address. - `SUBJECT_PREFIX`: **_empty_**: Prefix to be placed before e-mail subject lines. - `SENDMAIL_PATH`: **sendmail**: The location of sendmail on the operating system (can be command or full path). diff --git a/modules/setting/mailer.go b/modules/setting/mailer.go index a2bc2df444..b97080041f 100644 --- a/modules/setting/mailer.go +++ b/modules/setting/mailer.go @@ -26,6 +26,7 @@ type Mailer struct { FromEmail string `ini:"-"` SendAsPlainText bool `ini:"SEND_AS_PLAIN_TEXT"` SubjectPrefix string `ini:"SUBJECT_PREFIX"` + ReturnPath string `ini:"RETURN_PATH"` // SMTP sender Protocol string `ini:"PROTOCOL"` diff --git a/services/mailer/mailer.go b/services/mailer/mailer.go index 5e8e3dbb38..12de06d5e1 100644 --- a/services/mailer/mailer.go +++ b/services/mailer/mailer.go @@ -57,11 +57,14 @@ func (m *Message) ToMessage() *gomail.Message { msg.SetHeader(header, m.Headers[header]...) } - if len(setting.MailService.SubjectPrefix) > 0 { + if setting.MailService.SubjectPrefix != "" { msg.SetHeader("Subject", setting.MailService.SubjectPrefix+" "+m.Subject) } else { msg.SetHeader("Subject", m.Subject) } + if setting.MailService.ReturnPath != "" { + msg.SetHeader("Return-Path", setting.MailService.ReturnPath) + } msg.SetDateHeader("Date", m.Date) msg.SetHeader("X-Auto-Response-Suppress", "All") From 89a29c60cf31ff9bc771897cf2aff16f4f9e7bbf Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Wed, 1 Nov 2023 17:42:55 +0100 Subject: [PATCH 2/3] Update custom/conf/app.example.ini Co-authored-by: silverwind --- custom/conf/app.example.ini | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index 3e6d9a3581..ff6f709e0a 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -1578,8 +1578,7 @@ LEVEL = Info ;; Prefix displayed before subject in mail ;SUBJECT_PREFIX = ;; -;; Set the Return-Path header, to let mail clients reply to a different mail as it was send from. -;; If '<>' is set, it indicates has the same efect as if you would set a noreply address for FROM. +;; Set the Return-Path header where bounced e-mails will be sent to. ;RETURN_PATH = ;; ;; Mail server protocol. One of "smtp", "smtps", "smtp+starttls", "smtp+unix", "sendmail", "dummy". From 30db9c32abe02ab90fb41879b85be0781b07dc20 Mon Sep 17 00:00:00 2001 From: silverwind Date: Wed, 1 Nov 2023 18:11:02 +0100 Subject: [PATCH 3/3] Update docs/content/administration/config-cheat-sheet.en-us.md --- docs/content/administration/config-cheat-sheet.en-us.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/administration/config-cheat-sheet.en-us.md b/docs/content/administration/config-cheat-sheet.en-us.md index e82c4164bc..07986e7d5d 100644 --- a/docs/content/administration/config-cheat-sheet.en-us.md +++ b/docs/content/administration/config-cheat-sheet.en-us.md @@ -732,7 +732,7 @@ and - `ENABLE_HELO`: **true**: Enable HELO operation. - `HELO_HOSTNAME`: **(retrieved from system)**: HELO hostname. - `FROM`: **_empty_**: Mail from address, RFC 5322. This can be just an email address, or the "Name" \ format. -- `RETURN_PATH`: **_empty_**: Set the Return-Path header, to let mail clients reply to a different mail as it was send from. See [RFC 4021](https://www.rfc-editor.org/rfc/rfc4021#page-17) for more details. +- `RETURN_PATH`: **_empty_**: Set the Return-Path header where bounced e-mails will be sent to. - `ENVELOPE_FROM`: **_empty_**: Address set as the From address on the SMTP mail envelope. Set to `<>` to send an empty address. - `SUBJECT_PREFIX`: **_empty_**: Prefix to be placed before e-mail subject lines. - `SENDMAIL_PATH`: **sendmail**: The location of sendmail on the operating system (can be command or full path).