Authenticated SMTP is now fully functional.

Tweaked the newlines in the validation email.
This commit is contained in:
Azareal 2017-03-16 05:06:58 +00:00
parent 049131ef34
commit 27df532617
4 changed files with 13 additions and 11 deletions

View File

@ -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"

View File

@ -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"

View File

@ -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)
}

View File

@ -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