initial commit

This commit is contained in:
matyushev_mo committed 2024-12-06 16:10:35 +03:00
commit e8da0f7874
15 files changed
+722

No files matched your search

+23
View File
@@ -0,0 +1,23 @@
package utils
import (
"fmt"
"net/smtp"
c "desq.com.ru/testjwtauth/config"
)
func NotifyEmail(m string, r string) error {
a := smtp.PlainAuth("", c.SMTPEmail, c.SMTPPassword, c.SMTPHost)
message := "From: " + c.SMTPEmail + "\n" +
"To: " + r + "\n" +
"Subject: Access from an unknown IP\n\n" +
m
if err := smtp.SendMail(fmt.Sprintf("%s:%d", c.SMTPHost, 587), a, c.SMTPEmail, []string{r}, []byte(message)); err != nil {
return fmt.Errorf("failed to send email: %v", err)
}
return nil
}