1
0
mirror of https://github.com/mainflux/mainflux.git synced 2025-04-26 13:48:53 +08:00
Mirko Teodorovic 2453cd75ed
NOISSUE: Fix emailer (#1219)
* update swagger

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* dont return nil

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

* simplify emailer New

Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>

Co-authored-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>
2020-07-14 03:06:13 +02:00

30 lines
710 B
Go

// Copyright (c) Mainflux
// SPDX-License-Identifier: Apache-2.0
package emailer
import (
"fmt"
"github.com/mainflux/mainflux/internal/email"
"github.com/mainflux/mainflux/users"
)
var _ users.Emailer = (*emailer)(nil)
type emailer struct {
resetURL string
agent *email.Agent
}
// New creates new emailer utility
func New(url string, c *email.Config) (users.Emailer, error) {
e, err := email.New(c)
return &emailer{resetURL: url, agent: e}, err
}
func (e *emailer) SendPasswordReset(To []string, host string, token string) error {
url := fmt.Sprintf("%s%s?token=%s", host, e.resetURL, token)
content := fmt.Sprintf("%s", url)
return e.agent.Send(To, "", "Password reset", "", content, "")
}