feat(mail): #132 unify env variables and send mails with smtp
All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 46s

This commit is contained in:
Tim
2024-09-06 16:17:49 +02:00
parent 2c23a508ec
commit 6669e4adab
7 changed files with 105 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())
}
}