Browse Source

pkg/mailer: support custom mail subject prefix (#4524)

pull/4985/merge
Unknwon 7 years ago
parent
commit
17d789a785
No known key found for this signature in database
GPG Key ID: 25B575AE3213B2B3
  1. 4
      conf/app.ini
  2. 2
      conf/locale/locale_en-US.ini
  3. 2
      gogs.go
  4. 8
      pkg/bindata/bindata.go
  5. 2
      pkg/mailer/mailer.go
  6. 4
      pkg/setting/setting.go
  7. 2
      templates/.VERSION
  8. 4
      templates/admin/config.tmpl

4
conf/app.ini

@ -226,8 +226,8 @@ PAGING_NUM = 10
ENABLED = false ENABLED = false
; Buffer length of channel, keep it as it is if you don't know what it is. ; Buffer length of channel, keep it as it is if you don't know what it is.
SEND_BUFFER_LEN = 100 SEND_BUFFER_LEN = 100
; Name displayed in mail title ; Prefix prepended to the subject line
SUBJECT = %(APP_NAME)s SUBJECT_PREFIX = `[%(APP_NAME)s] `
; Mail server ; Mail server
; Gmail: smtp.gmail.com:587 ; Gmail: smtp.gmail.com:587
; QQ: smtp.qq.com:465 ; QQ: smtp.qq.com:465

2
conf/locale/locale_en-US.ini

@ -1211,7 +1211,7 @@ config.skip_tls_verify = Skip TLS Verify
config.mailer_config = Mailer Configuration config.mailer_config = Mailer Configuration
config.mailer_enabled = Enabled config.mailer_enabled = Enabled
config.mailer_disable_helo = Disable HELO config.mailer_disable_helo = Disable HELO
config.mailer_name = Name config.mailer_subject_prefix = Subject Prefix
config.mailer_host = Host config.mailer_host = Host
config.mailer_user = User config.mailer_user = User
config.send_test_mail = Send Test Email config.send_test_mail = Send Test Email

2
gogs.go

@ -16,7 +16,7 @@ import (
"github.com/gogits/gogs/pkg/setting" "github.com/gogits/gogs/pkg/setting"
) )
const APP_VER = "0.11.42.0330" const APP_VER = "0.11.43.0330"
func init() { func init() {
setting.AppVer = APP_VER setting.AppVer = APP_VER

8
pkg/bindata/bindata.go

File diff suppressed because one or more lines are too long

2
pkg/mailer/mailer.go

@ -34,7 +34,7 @@ func NewMessageFrom(to []string, from, subject, htmlBody string) *Message {
msg := gomail.NewMessage() msg := gomail.NewMessage()
msg.SetHeader("From", from) msg.SetHeader("From", from)
msg.SetHeader("To", to...) msg.SetHeader("To", to...)
msg.SetHeader("Subject", subject) msg.SetHeader("Subject", setting.MailService.SubjectPrefix+subject)
msg.SetDateHeader("Date", time.Now()) msg.SetDateHeader("Date", time.Now())
contentType := "text/html" contentType := "text/html"

4
pkg/setting/setting.go

@ -821,7 +821,7 @@ func newSessionService() {
// Mailer represents mail service. // Mailer represents mail service.
type Mailer struct { type Mailer struct {
QueueLength int QueueLength int
Subject string SubjectPrefix string
Host string Host string
From string From string
FromEmail string FromEmail string
@ -848,7 +848,7 @@ func newMailService() {
MailService = &Mailer{ MailService = &Mailer{
QueueLength: sec.Key("SEND_BUFFER_LEN").MustInt(100), QueueLength: sec.Key("SEND_BUFFER_LEN").MustInt(100),
Subject: sec.Key("SUBJECT").MustString(AppName), SubjectPrefix: sec.Key("SUBJECT_PREFIX").MustString("[" + AppName + "] "),
Host: sec.Key("HOST").String(), Host: sec.Key("HOST").String(),
User: sec.Key("USER").String(), User: sec.Key("USER").String(),
Passwd: sec.Key("PASSWD").String(), Passwd: sec.Key("PASSWD").String(),

2
templates/.VERSION

@ -1 +1 @@
0.11.42.0330 0.11.43.0330

4
templates/admin/config.tmpl

@ -190,8 +190,8 @@
<dt>{{.i18n.Tr "admin.config.mailer_enabled"}}</dt> <dt>{{.i18n.Tr "admin.config.mailer_enabled"}}</dt>
<dd><i class="fa fa{{if .MailerEnabled}}-check{{end}}-square-o"></i></dd> <dd><i class="fa fa{{if .MailerEnabled}}-check{{end}}-square-o"></i></dd>
{{if .MailerEnabled}} {{if .MailerEnabled}}
<dt>{{.i18n.Tr "admin.config.mailer_name"}}</dt> <dt>{{.i18n.Tr "admin.config.mailer_subject_prefix"}}</dt>
<dd>{{.Mailer.Subject}}</dd> <dd><code>{{.Mailer.SubjectPrefix}}</code></dd>
<dt>{{.i18n.Tr "admin.config.mailer_disable_helo"}}</dt> <dt>{{.i18n.Tr "admin.config.mailer_disable_helo"}}</dt>
<dd><i class="fa fa{{if .Mailer.DisableHelo}}-check{{end}}-square-o"></i></dd> <dd><i class="fa fa{{if .Mailer.DisableHelo}}-check{{end}}-square-o"></i></dd>
<dt>{{.i18n.Tr "admin.config.mailer_host"}}</dt> <dt>{{.i18n.Tr "admin.config.mailer_host"}}</dt>

Loading…
Cancel
Save