Skip to content

Sendmail command #13079

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Oct 24, 2020
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
016b35b
Add SendSync method
zhiburt Oct 8, 2020
538d0db
Add sendmail command
zhiburt Oct 8, 2020
8ecbcc7
add checks that if either title or content is empty then error out
zhiburt Oct 9, 2020
5c0524a
Add a confirmation step
zhiburt Oct 9, 2020
2abad3e
Add --force option to bypass confirm step
zhiburt Oct 9, 2020
9c98e13
Move implementation of runSendMail to a different file
zhiburt Oct 9, 2020
a750b18
Add copyrighting comment
zhiburt Oct 9, 2020
3cb7d18
Make content optional
zhiburt Oct 12, 2020
d3723b5
Fix import style
zhiburt Oct 12, 2020
087129c
Merge branch 'master' of https://github.com/go-gitea/gitea into sendm…
zhiburt Oct 15, 2020
2ed24b5
Use batch when getting all users
zhiburt Oct 15, 2020
6f4b38d
Merge branch 'sendmail_command' of github.com:zhiburt/gitea into send…
zhiburt Oct 15, 2020
59a1bee
Send emails one by one instead of as one chunck
zhiburt Oct 16, 2020
f5a108d
Send messages concurantly
zhiburt Oct 16, 2020
5b5f8c5
Use SendAsync+Flush instead of SendSync
zhiburt Oct 19, 2020
042c259
Add timeout parameter to sendemail command
zhiburt Oct 19, 2020
a25d8be
Fix spelling mistake
zhiburt Oct 19, 2020
b350eea
Update cmd/admin.go
zhiburt Oct 23, 2020
3d5b393
Connect to a running Gitea instance
zhiburt Oct 23, 2020
cee82ff
Merge branch 'sendmail_command' of github.com:zhiburt/gitea into send…
zhiburt Oct 23, 2020
6968eb9
Fix mispelling
zhiburt Oct 23, 2020
af3cff6
Add copyright comment
zhiburt Oct 23, 2020
b959bf1
Merge branch 'master' into sendmail_command
lunny Oct 24, 2020
1b9f0ee
Merge branch 'master' into sendmail_command
techknowlogick Oct 24, 2020
490fa03
Merge branch 'master' into sendmail_command
techknowlogick Oct 24, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions cmd/mailer.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,6 @@ func runSendMail(c *cli.Context) error {
return err
}

var emails []string
err := models.IterateUser(func(user *models.User) error {
emails = append(emails, user.Email)
return nil
})
if err != nil {
return errors.New("Cann't find users")
}

subject := c.String("title")
confirmSkiped := c.Bool("force")
body := c.String("content")
Expand All @@ -51,11 +42,22 @@ func runSendMail(c *cli.Context) error {
}
}

mailer.NewContext()
msg := mailer.NewMessage(emails, subject, body)
err = mailer.SendSync(msg)
var emails []string
err := models.IterateUser(func(user *models.User) error {
emails = append(emails, user.Email)
return nil
})
if err != nil {
return err
return errors.New("Cann't find users")
}

mailer.NewContext()
for _, email := range emails {
msg := mailer.NewMessage([]string{email}, subject, body)
err = mailer.SendSync(msg)
if err != nil {
return err
}
}

return nil
Expand Down