diff --git a/config.go b/config.go index 97b9d4e8..25346213 100644 --- a/config.go +++ b/config.go @@ -26,6 +26,7 @@ var site_email = "" // Should be a setting var smtp_server = "" var smtp_username = "" var smtp_password = "" +var smtp_port = "25" //var noavatar = "https://api.adorable.io/avatars/{width}/{id}@{site_url}.png" var noavatar = "https://api.adorable.io/avatars/285/{id}@" + site_url + ".png" diff --git a/install/install.go b/install/install.go index ad7b2b4f..12da223f 100644 --- a/install/install.go +++ b/install/install.go @@ -164,6 +164,7 @@ var site_email = "" // Should be a setting var smtp_server = "" var smtp_username = "" var smtp_password = "" +var smtp_port = "25" //var noavatar = "https://api.adorable.io/avatars/{width}/{id}@{site_url}.png" var noavatar = "https://api.adorable.io/avatars/285/{id}@" + site_url + ".png" diff --git a/user.go b/user.go index e1cdb61b..f3155ab4 100644 --- a/user.go +++ b/user.go @@ -315,7 +315,7 @@ func SendValidationEmail(username string, email string, token string) bool { } subject := "Validate Your Email @ " + site_name - msg := "Dear " + username + ", following your registration on our forums, we ask you to validate your email, so that we can confirm that this email actually belongs to you.\nClick on the following link to do so. http" + schema + "://" + site_url + "/user/edit/token/" + token + "\nIf you haven't created an account here, then please feel free to ignore this email.\nWe're sorry for the inconvenience this may have caused." + msg := "Dear " + username + ", following your registration on our forums, we ask you to validate your email, so that we can confirm that this email actually belongs to you.\n\nClick on the following link to do so. http" + schema + "://" + site_url + "/user/edit/token/" + token + "\n\nIf you haven't created an account here, then please feel free to ignore this email.\nWe're sorry for the inconvenience this may have caused." return SendEmail(email, subject, msg) } diff --git a/utils.go b/utils.go index 13d65fa2..487b69e6 100644 --- a/utils.go +++ b/utils.go @@ -73,16 +73,7 @@ func SendEmail(email string, subject string, msg string) bool { } body := "Subject: " + subject + "\n\n" + msg + "\n" - con, err := smtp.Dial(smtp_server) - if err != nil { - return false - } - - err = con.Mail(site_email) - if err != nil { - return false - } - err = con.Rcpt(email) + con, err := smtp.Dial(smtp_server + ":" + smtp_port) if err != nil { return false } @@ -95,6 +86,15 @@ func SendEmail(email string, subject string, msg string) bool { } } + err = con.Mail(site_email) + if err != nil { + return false + } + err = con.Rcpt(email) + if err != nil { + return false + } + email_data, err := con.Data() if err != nil { return false