Skip to content
Snippets Groups Projects

Revert "Default and warnings in email_config.toml"

Merged Linus requested to merge revert-2a6c7e14 into master
2 files
+ 8
25
Compare changes
  • Side-by-side
  • Inline

Files

+ 6
24
@@ -3,7 +3,6 @@ package mail
import (
"errors"
"io/ioutil"
"log"
"math/rand"
"net/smtp"
"strconv"
@@ -41,11 +40,9 @@ func GetEmail(id string) (string, error) {
}
type emailConfig struct {
Email string
Password string
SmtpServer string
Port string
Location string
Email string
Password string
Location string
}
var config emailConfig
@@ -61,8 +58,8 @@ func Send(to string, subject string, body string) error {
"Subject: " + subject + "\n\n" +
body
err := smtp.SendMail(config.Email+":"+config.Port,
smtp.PlainAuth("", from, pass, config.Email),
err := smtp.SendMail("smtp.gmail.com:587",
smtp.PlainAuth("", from, pass, "smtp.gmail.com"),
from, []string{to}, []byte(msg))
if err != nil {
@@ -75,26 +72,11 @@ func Send(to string, subject string, body string) error {
func LoadConfig(path string) error {
data, err := ioutil.ReadFile(path)
if err != nil {
config = emailConfig{}
log.Println("Warning: No email config found. You won't be able to send emails.")
log.Println("To fix this, please create an email_config.toml in your data folder " +
"with arguments Email, Password, Location (your apb url, like https://abgabepartner.de) " +
"SmtpServer (optional, default smtp.gmail.com) and Port (optional, default 587)")
return nil
return err
}
if _, err := toml.Decode(string(data), &config); err != nil {
return err
}
server := "smtp.gmail.com"
port := "587"
if config.SmtpServer == "" {
config.SmtpServer = server
log.Println("Email config: No SmtpServer specified. Defaulting to " + server)
}
if config.Port == "" {
config.Port = port
log.Println("Email config: No Port specified. Defaulting to " + port)
}
URL = config.Location
return nil
}
Loading