feat(mail): #132 unify env variables and send mails with smtp

This commit is contained in:
2024-09-05 17:54:39 +02:00
parent 0872728f3a
commit 5172a30781
7 changed files with 111 additions and 22 deletions

19
utils/mail.go Normal file
View File

@@ -0,0 +1,19 @@
package utils
import (
"log/slog"
"net/smtp"
)
func SendWelcomeMail(to string) {
auth := smtp.PlainAuth("", SmtpUser, SmtpPass, SmtpHost)
msg := "From: " + SmtpFromName + " <" + SmtpFromMail + ">\nTo: " + to + "\nSubject: Welcome to me-fit\n\nWelcome to me-fit!"
err := smtp.SendMail(SmtpHost+":"+SmtpPort, auth, SmtpFromMail, []string{to}, []byte(msg))
if err != nil {
slog.Error("Could not send mail: " + err.Error())
}
}