summaryrefslogtreecommitdiff
path: root/internal/email/confirm.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/email/confirm.go')
-rw-r--r--internal/email/confirm.go35
1 files changed, 19 insertions, 16 deletions
diff --git a/internal/email/confirm.go b/internal/email/confirm.go
index 94aebc61f..a6548e7d1 100644
--- a/internal/email/confirm.go
+++ b/internal/email/confirm.go
@@ -21,8 +21,7 @@ import (
"bytes"
"net/smtp"
- "github.com/superseriousbusiness/gotosocial/internal/config"
- "github.com/superseriousbusiness/gotosocial/internal/log"
+ "github.com/superseriousbusiness/gotosocial/internal/gtserror"
)
const (
@@ -30,6 +29,19 @@ const (
confirmSubject = "GoToSocial Email Confirmation"
)
+// ConfirmData represents data passed into the confirm email address template.
+type ConfirmData struct {
+ // Username to be addressed.
+ Username string
+ // URL of the instance to present to the receiver.
+ InstanceURL string
+ // Name of the instance to present to the receiver.
+ InstanceName string
+ // Link to present to the receiver to click on and do the confirmation.
+ // Should be a full link with protocol eg., https://example.org/confirm_email?token=some-long-token
+ ConfirmLink string
+}
+
func (s *sender) SendConfirmEmail(toAddress string, data ConfirmData) error {
buf := &bytes.Buffer{}
if err := s.template.ExecuteTemplate(buf, confirmTemplate, data); err != nil {
@@ -41,19 +53,10 @@ func (s *sender) SendConfirmEmail(toAddress string, data ConfirmData) error {
if err != nil {
return err
}
- log.Trace(nil, s.hostAddress+"\n"+config.GetSMTPUsername()+":password"+"\n"+s.from+"\n"+toAddress+"\n\n"+string(msg)+"\n")
- return smtp.SendMail(s.hostAddress, s.auth, s.from, []string{toAddress}, msg)
-}
-// ConfirmData represents data passed into the confirm email address template.
-type ConfirmData struct {
- // Username to be addressed.
- Username string
- // URL of the instance to present to the receiver.
- InstanceURL string
- // Name of the instance to present to the receiver.
- InstanceName string
- // Link to present to the receiver to click on and do the confirmation.
- // Should be a full link with protocol eg., https://example.org/confirm_email?token=some-long-token
- ConfirmLink string
+ if err := smtp.SendMail(s.hostAddress, s.auth, s.from, []string{toAddress}, msg); err != nil {
+ return gtserror.SetType(err, gtserror.TypeSMTP)
+ }
+
+ return nil
}