Browse Source

Golint fixed for modules/mailer

tags/v1.0.0
Lunny Xiao 7 years ago
parent
commit
2e565bc1c4
1 changed files with 8 additions and 1 deletions
  1. 8
    1
      modules/mailer/mailer.go

+ 8
- 1
modules/mailer/mailer.go View File

"code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/setting"
) )


// Message mail body and log info
type Message struct { type Message struct {
Info string // Message information for log purpose. Info string // Message information for log purpose.
*gomail.Message *gomail.Message
username, password string username, password string
} }


// SMTP AUTH LOGIN Auth Handler
// LoginAuth SMTP AUTH LOGIN Auth Handler
func LoginAuth(username, password string) smtp.Auth { func LoginAuth(username, password string) smtp.Auth {
return &loginAuth{username, password} return &loginAuth{username, password}
} }


// Start start SMTP login auth
func (a *loginAuth) Start(server *smtp.ServerInfo) (string, []byte, error) { func (a *loginAuth) Start(server *smtp.ServerInfo) (string, []byte, error) {
return "LOGIN", []byte{}, nil return "LOGIN", []byte{}, nil
} }


// Next next step of SMTP login auth
func (a *loginAuth) Next(fromServer []byte, more bool) ([]byte, error) { func (a *loginAuth) Next(fromServer []byte, more bool) ([]byte, error) {
if more { if more {
switch string(fromServer) { switch string(fromServer) {
return nil, nil return nil, nil
} }


// Sender mail sender
type Sender struct { type Sender struct {
} }


// Send send email
func (s *Sender) Send(from string, to []string, msg io.WriterTo) error { func (s *Sender) Send(from string, to []string, msg io.WriterTo) error {
opts := setting.MailService opts := setting.MailService




var mailQueue chan *Message var mailQueue chan *Message


// NewContext start mail queue service
func NewContext() { func NewContext() {
// Need to check if mailQueue is nil because in during reinstall (user had installed // Need to check if mailQueue is nil because in during reinstall (user had installed
// before but swithed install lock off), this function will be called again // before but swithed install lock off), this function will be called again
go processMailQueue() go processMailQueue()
} }


// SendAsync send mail asynchronous
func SendAsync(msg *Message) { func SendAsync(msg *Message) {
go func() { go func() {
mailQueue <- msg mailQueue <- msg

Loading…
Cancel
Save