Browse Source

Merge pull request #2660 from joshfng/config-test-mailer

Test mailer button. Addresses #1531
for-closed-social
Unknwon 8 years ago
parent
commit
5418c2c5e4
6 changed files with 708 additions and 907 deletions
  1. +1
    -0
      cmd/web.go
  2. +1
    -0
      conf/locale/locale_en-US.ini
  3. +690
    -906
      modules/bindata/bindata.go
  4. +6
    -0
      modules/mailer/mail.go
  5. +8
    -0
      routers/admin/admin.go
  6. +2
    -1
      templates/admin/config.tmpl

+ 1
- 0
cmd/web.go View File

@ -250,6 +250,7 @@ func runWeb(ctx *cli.Context) {
m.Group("/admin", func() { m.Group("/admin", func() {
m.Get("", adminReq, admin.Dashboard) m.Get("", adminReq, admin.Dashboard)
m.Get("/config", admin.Config) m.Get("/config", admin.Config)
m.Get("/config/testmailer", admin.TestMailer)
m.Get("/monitor", admin.Monitor) m.Get("/monitor", admin.Monitor)
m.Group("/users", func() { m.Group("/users", func() {

+ 1
- 0
conf/locale/locale_en-US.ini View File

@ -989,6 +989,7 @@ config.mailer_disable_helo = Disable HELO
config.mailer_name = Name config.mailer_name = Name
config.mailer_host = Host config.mailer_host = Host
config.mailer_user = User config.mailer_user = User
config.mailer_test_email = Test Email Settings
config.oauth_config = OAuth Configuration config.oauth_config = OAuth Configuration
config.oauth_enabled = Enabled config.oauth_enabled = Enabled
config.cache_config = Cache Configuration config.cache_config = Cache Configuration

+ 690
- 906
modules/bindata/bindata.go
File diff suppressed because it is too large
View File


+ 6
- 0
modules/mailer/mail.go View File

@ -183,3 +183,9 @@ func SendCollaboratorMail(r macaron.Render, u, doer *models.User, repo *models.R
SendAsync(msg) SendAsync(msg)
return nil return nil
} }
func SendTestMail(u *models.User) {
msg := NewMessage([]string{u.Email}, "Gogs Test Email!", "Gogs Test Email!")
SendAsync(msg)
}

+ 8
- 0
routers/admin/admin.go View File

@ -16,6 +16,7 @@ import (
"github.com/gogits/gogs/models" "github.com/gogits/gogs/models"
"github.com/gogits/gogs/modules/base" "github.com/gogits/gogs/modules/base"
"github.com/gogits/gogs/modules/cron" "github.com/gogits/gogs/modules/cron"
"github.com/gogits/gogs/modules/mailer"
"github.com/gogits/gogs/modules/middleware" "github.com/gogits/gogs/modules/middleware"
"github.com/gogits/gogs/modules/process" "github.com/gogits/gogs/modules/process"
"github.com/gogits/gogs/modules/setting" "github.com/gogits/gogs/modules/setting"
@ -174,6 +175,13 @@ func Dashboard(ctx *middleware.Context) {
ctx.HTML(200, DASHBOARD) ctx.HTML(200, DASHBOARD)
} }
func TestMailer(ctx *middleware.Context) {
// send a test email to the user's email address and redirect back to Config
mailer.SendTestMail(ctx.User)
ctx.Redirect(setting.AppSubUrl + "/admin/config")
}
func Config(ctx *middleware.Context) { func Config(ctx *middleware.Context) {
ctx.Data["Title"] = ctx.Tr("admin.config") ctx.Data["Title"] = ctx.Tr("admin.config")
ctx.Data["PageIsAdmin"] = true ctx.Data["PageIsAdmin"] = true

+ 2
- 1
templates/admin/config.tmpl View File

@ -116,7 +116,8 @@
<dt>{{.i18n.Tr "admin.config.mailer_host"}}</dt> <dt>{{.i18n.Tr "admin.config.mailer_host"}}</dt>
<dd>{{.Mailer.Host}}</dd> <dd>{{.Mailer.Host}}</dd>
<dt>{{.i18n.Tr "admin.config.mailer_user"}}</dt> <dt>{{.i18n.Tr "admin.config.mailer_user"}}</dt>
<dd>{{.Mailer.User}}</dd>{{end}}
<dd>{{.Mailer.User}}</dd><br>
<a class="ui green button" tabindex="5" href="/admin/config/testmailer">{{.i18n.Tr "admin.config.mailer_test_email"}}</a>{{end}}
</dl> </dl>
</div> </div>

Loading…
Cancel
Save