wip: added contact form handling
This commit is contained in:
@@ -1,13 +1,15 @@
|
||||
package services
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"html/template"
|
||||
|
||||
"gopkg.in/gomail.v2"
|
||||
|
||||
"GoMembership/internal/config"
|
||||
"GoMembership/internal/constants"
|
||||
"GoMembership/internal/models"
|
||||
"GoMembership/pkg/logger"
|
||||
"bytes"
|
||||
"gopkg.in/gomail.v2"
|
||||
"html/template"
|
||||
)
|
||||
|
||||
type EmailService struct {
|
||||
@@ -152,3 +154,22 @@ func (s *EmailService) NotifyAdminOfNewUser(user *models.User) error {
|
||||
}
|
||||
return s.SendEmail(config.SMTP.AdminEmail, subject, body)
|
||||
}
|
||||
|
||||
func (s *EmailService) RelayContactFormMessage(sender string, name string, message string) error {
|
||||
data := struct {
|
||||
Message string
|
||||
Name string
|
||||
BASEURL string
|
||||
}{
|
||||
Message: message,
|
||||
Name: name,
|
||||
BASEURL: config.BaseURL,
|
||||
}
|
||||
subject := constants.MailContactSubject
|
||||
body, err := ParseTemplate("mail_contact_form.html", data)
|
||||
if err != nil {
|
||||
logger.Error.Print("Couldn't send contact form message mail")
|
||||
return err
|
||||
}
|
||||
return s.SendEmail(config.SMTP.AdminEmail, subject, body)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user