This commit is contained in:
6543 2024-04-30 21:59:56 +03:00 committed by GitHub
commit c4ea7852f8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 9 additions and 1 deletions

View File

@ -1622,6 +1622,9 @@ LEVEL = Info
;; Prefix displayed before subject in mail
;SUBJECT_PREFIX =
;;
;; 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".
;; - 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.

View File

@ -752,6 +752,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" \<email@example.com\> format.
- `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).

View File

@ -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"`

View File

@ -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")