changed contact form reply_to and response html

This commit is contained in:
$(pass /github/name)
2024-08-21 12:29:13 +02:00
parent 3224536e56
commit ee66835649
5 changed files with 34 additions and 14 deletions

View File

@@ -21,11 +21,14 @@ func NewEmailService(host string, port int, username string, password string) *E
return &EmailService{dialer: dialer}
}
func (s *EmailService) SendEmail(to string, subject string, body string) error {
func (s *EmailService) SendEmail(to string, subject string, body string, replyTo string) error {
msg := gomail.NewMessage()
msg.SetHeader("From", s.dialer.Username)
msg.SetHeader("To", to)
msg.SetHeader("Subject", subject)
if replyTo != "" {
msg.SetHeader("REPLY_TO", replyTo)
}
msg.SetBody("text/html", body)
if err := s.dialer.DialAndSend(msg); err != nil {
@@ -76,7 +79,7 @@ func (s *EmailService) SendVerificationEmail(user *models.User, token *string) e
logger.Error.Print("Couldn't send verification mail")
return err
}
return s.SendEmail(user.Email, subject, body)
return s.SendEmail(user.Email, subject, body, "")
}
@@ -106,7 +109,7 @@ func (s *EmailService) SendWelcomeEmail(user *models.User) error {
logger.Error.Print("Couldn't send welcome mail")
return err
}
return s.SendEmail(user.Email, subject, body)
return s.SendEmail(user.Email, subject, body, "")
}
func (s *EmailService) SendRegistrationNotification(user *models.User) error {
@@ -151,7 +154,7 @@ func (s *EmailService) SendRegistrationNotification(user *models.User) error {
logger.Error.Print("Couldn't send admin notification mail")
return err
}
return s.SendEmail(config.Recipients.UserRegistration, subject, body)
return s.SendEmail(config.Recipients.UserRegistration, subject, body, "")
}
func (s *EmailService) RelayContactFormMessage(sender string, name string, message string) error {
@@ -170,5 +173,5 @@ func (s *EmailService) RelayContactFormMessage(sender string, name string, messa
logger.Error.Print("Couldn't send contact form message mail")
return err
}
return s.SendEmail(config.Recipients.ContactForm, subject, body)
return s.SendEmail(config.Recipients.ContactForm, subject, body, sender)
}