Skip to content

Commit

Permalink
Set comments to exported methods of mailgun backend
Browse files Browse the repository at this point in the history
  • Loading branch information
teran committed May 9, 2018
1 parent 4877a1a commit 3f19a43
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions backend/mailgun/mailgun.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ type Backend struct {
publicKey string
}

// User type
type User struct {
mailgunClient mg.Mailgun
}

// NewBackend returns new instance of backend
func NewBackend(domain, privateKey, publicKey string) (smtp.Backend, error) {
if domain == "" || privateKey == "" || publicKey == "" {
return nil, fmt.Errorf("domain, privateKey, publicKey must not be empty")
Expand All @@ -37,18 +39,23 @@ func NewBackend(domain, privateKey, publicKey string) (smtp.Backend, error) {
}, nil
}

// Login is used to authenticate the user
// In relay there's no need for that at the moment
func (b *Backend) Login(username, password string) (smtp.User, error) {
return &User{
mailgunClient: mg.NewMailgun(b.Domain, b.privateKey, b.publicKey),
}, nil
}

// AnonymousLogin returns anonymouse user object
func (b *Backend) AnonymousLogin() (smtp.User, error) {
return &User{
mailgunClient: mg.NewMailgun(b.Domain, b.privateKey, b.publicKey),
}, nil
}

// Send will send email synchronously via Mailgun service
// TODO: Send messages via queue
func (u *User) Send(from string, to []string, r io.Reader) error {
m, err := mail.ReadMessage(r)
if err != nil {
Expand All @@ -71,6 +78,8 @@ func (u *User) Send(from string, to []string, r io.Reader) error {
return nil
}

// Logout is calle after all operations are complete within the session
// Here in relay there's no need to implement anything special for that
func (u *User) Logout() error {
return nil
}

0 comments on commit 3f19a43

Please sign in to comment.