move structs in right packages + impl sender service to build and send e-mail
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// mandatory parameters for the STMP server connection
|
||||
type SMTPConfig struct {
|
||||
User string
|
||||
Password string
|
||||
Url string
|
||||
Port string
|
||||
}
|
||||
|
||||
func NewSMTPConfig(user, password, url, port string) (SMTPConfig, error) {
|
||||
var config SMTPConfig
|
||||
if user == "" {
|
||||
return config, errors.New("SMTP user can't be empty")
|
||||
}
|
||||
config.User = user
|
||||
|
||||
if password == "" {
|
||||
return config, errors.New("SMTP password can't be empty")
|
||||
}
|
||||
config.Password = password
|
||||
|
||||
if url == "" {
|
||||
return config, errors.New("SMTP server url can't be empty")
|
||||
}
|
||||
config.Url = url
|
||||
|
||||
if port == "" {
|
||||
return config, errors.New("SMTP server port can't be empty")
|
||||
}
|
||||
config.Port = port
|
||||
|
||||
return config, nil
|
||||
}
|
||||
|
||||
func (c SMTPConfig) GetFullUrl() string {
|
||||
return fmt.Sprintf("%s:%s", c.Url, c.Port)
|
||||
}
|
||||
Reference in New Issue
Block a user