44 lines
		
	
	
		
			819 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			44 lines
		
	
	
		
			819 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| 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)
 | |
| }
 |