feat(auth): #154 send verification mails
This commit is contained in:
@@ -1,19 +1,15 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
"fmt"
|
||||
"net/smtp"
|
||||
)
|
||||
|
||||
func SendWelcomeMail(to string) {
|
||||
func SendMail(to string, subject string, message string) error {
|
||||
|
||||
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())
|
||||
}
|
||||
msg := fmt.Sprintf("From: %v <%v>\nTo: %v\nSubject: %v\nMIME-version: 1.0;\nContent-Type: text/html; charset=\"UTF-8\";\n\n%v", SmtpFromName, SmtpFromMail, to, subject, message)
|
||||
|
||||
return smtp.SendMail(SmtpHost+":"+SmtpPort, auth, SmtpFromMail, []string{to}, []byte(msg))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user