api.spaceplanner.app

Spaceplanner API
git clone git://jacobedwards.org/api.spaceplanner.app
Log | Files | Refs

commit 400c878a4de7358729c952a41cfa1e5c5a3d1ec0
parent 9a1dade58be5b2051062f3beddc5da0412681aa6
Author: Jacob R. Edwards <jacob@jacobedwards.org>
Date:   Fri, 30 Aug 2024 18:42:21 -0700

Fix email sending and configuration

I'm great at this. Forgot to make sure email was still working after
adding the configuration file.

Diffstat:
Minternal/backend/config.go | 2+-
Minternal/backend/user.go | 8+++++---
2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/internal/backend/config.go b/internal/backend/config.go @@ -22,5 +22,5 @@ type SMTPConfig struct { // Password to authenticate with Password string `json:"password" binding:"required"` // Name given in From: header - Name string `json:"from" binding:"required"` + Name string `json:"name" binding:"required"` } diff --git a/internal/backend/user.go b/internal/backend/user.go @@ -186,7 +186,7 @@ func (e *Env) SendVerificationEmail(username string) error { } body := fmt.Sprintf( -`From: %s <%s> +`From: %s <%s@%s> To: %s Subject: Your Spaceplanner.app verification code @@ -197,11 +197,13 @@ Your email verification code is It expires after 15 minutes. If you did not try and set your email for spaceplanner.app, you can -safely ignore this message (and sorry to bother).`, e.Config.SMTP.Name, e.Config.SMTP.Server, *emails.Setting, code) +safely ignore this message (and sorry to bother).`, e.Config.SMTP.Name, e.Config.SMTP.User, + e.Config.SMTP.Server, *emails.Setting, code) addrs := []string{*emails.Setting} log.Printf("Sending authentication code to %s at request of %s", *emails.Setting, username) - return smtp.SendMail(e.Config.SMTP.Server, e.SMTPAuth, e.Config.SMTP.Name, addrs, []byte(body)) + return smtp.SendMail(e.Config.SMTP.Server + ":" + e.Config.SMTP.Port, + e.SMTPAuth, e.Config.SMTP.User + "@" + e.Config.SMTP.Server, addrs, []byte(body)) } func (e *Env) UserEmails(username string) (UserEmails, error) {