move structs in right packages + impl sender service to build and send e-mail

This commit is contained in:
2022-10-15 13:58:03 +00:00
parent 7811a25c09
commit 9a90c8dc3a
4 changed files with 182 additions and 92 deletions
+43
View File
@@ -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)
}