mirror of
https://github.com/mainflux/mainflux.git
synced 2025-05-04 22:17:59 +08:00

* remove single case switch remove duplicate cases Signed-off-by: SammyOina <sammyoina@gmail.com> * remove single case switch \n format comments Signed-off-by: SammyOina <sammyoina@gmail.com> * graceful exit on main func Signed-off-by: SammyOina <sammyoina@gmail.com> * remove fatal from imported packages Signed-off-by: SammyOina <sammyoina@gmail.com> * reuse exit function Signed-off-by: SammyOina <sammyoina@gmail.com> * return nill for empty configs Signed-off-by: SammyOina <sammyoina@gmail.com> * return nil for config file not found Signed-off-by: SammyOina <sammyoina@gmail.com> --------- Signed-off-by: SammyOina <sammyoina@gmail.com> Co-authored-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
30 lines
698 B
Go
30 lines
698 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/clients"
|
|
)
|
|
|
|
var _ clients.Emailer = (*emailer)(nil)
|
|
|
|
type emailer struct {
|
|
resetURL string
|
|
agent *email.Agent
|
|
}
|
|
|
|
// New creates new emailer utility.
|
|
func New(url string, c *email.Config) (clients.Emailer, error) {
|
|
e, err := email.New(c)
|
|
return &emailer{resetURL: url, agent: e}, err
|
|
}
|
|
|
|
func (e *emailer) SendPasswordReset(to []string, host, user, token string) error {
|
|
url := fmt.Sprintf("%s%s?token=%s", host, e.resetURL, token)
|
|
return e.agent.Send(to, "", "Password Reset Request", "", user, url, "")
|
|
}
|