Browse Source

Test mailer button. Addresses #1531

pull/2660/head
Josh Frye 9 years ago
parent
commit
c27038e392
  1. 1
      cmd/web.go
  2. 1
      conf/locale/locale_en-US.ini
  3. 1596
      modules/bindata/bindata.go
  4. 6
      modules/mailer/mail.go
  5. 8
      routers/admin/admin.go
  6. 3
      templates/admin/config.tmpl

1
cmd/web.go

@ -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
conf/locale/locale_en-US.ini

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

1596
modules/bindata/bindata.go

File diff suppressed because one or more lines are too long

6
modules/mailer/mail.go

@ -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
routers/admin/admin.go

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

3
templates/admin/config.tmpl

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