town/cmd/help/email.go

41 lines
792 B
Go
Raw Normal View History

2023-10-25 02:41:02 +00:00
package main
import (
"fmt"
"git.tilde.town/tildetown/town/email"
"git.tilde.town/tildetown/town/towndb"
)
const emailText = `hello!
You (hopefully) requested to add a new public key to your tilde.town account.
If you didn't, feel free to ignore this email (or report it to an admin).
If you did, here is your auth code: %s
To use this code, please open a terminal and run:
ssh help@tilde.town
Follow the instructions there to add your new key and restore access to your account.
best,
~vilmibm`
func sendAuthCodeEmail(ac towndb.AuthCode) error {
pw, err := email.LoadPassword()
if err != nil {
return err
}
body := fmt.Sprintf(emailText, ac.Code)
mailer := email.NewExternalMailer(pw)
return mailer.Send(
ac.Email,
"Adding a new tilde.town public key",
body)
}