feat(mail): #132 unify env variables and send mails with smtp
This commit is contained in:
19
utils/mail.go
Normal file
19
utils/mail.go
Normal 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())
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user