add: Environment Var support
This commit is contained in:
@@ -37,7 +37,7 @@ func (s *EmailService) SendEmail(to string, subject string, body string) error {
|
||||
func ParseTemplate(filename string, data interface{}) (string, error) {
|
||||
// Read the email template file
|
||||
|
||||
templateDir := config.LoadConfig().Templates.MailDir
|
||||
templateDir := config.Templates.MailDir
|
||||
tpl, err := template.ParseFiles(templateDir + "/" + filename)
|
||||
if err != nil {
|
||||
logger.Error.Printf("Failed to parse email template: %v", err)
|
||||
@@ -106,20 +106,20 @@ func (s *EmailService) SendWelcomeEmail(user *models.User) error {
|
||||
func (s *EmailService) NotifyAdminOfNewUser(user *models.User) error {
|
||||
// Prepare data to be injected into the template
|
||||
data := struct {
|
||||
Company string
|
||||
FirstName string
|
||||
City string
|
||||
Email string
|
||||
LastName string
|
||||
MembershipModel string
|
||||
MembershipID int64
|
||||
MembershipFee float32
|
||||
RentalFee float32
|
||||
Address string
|
||||
ZipCode string
|
||||
City string
|
||||
DateOfBirth string
|
||||
Email string
|
||||
Phone string
|
||||
IBAN string
|
||||
FirstName string
|
||||
Phone string
|
||||
DateOfBirth string
|
||||
Company string
|
||||
ZipCode string
|
||||
MembershipID int64
|
||||
RentalFee float32
|
||||
MembershipFee float32
|
||||
}{
|
||||
Company: *user.Company,
|
||||
FirstName: user.FirstName,
|
||||
@@ -143,5 +143,5 @@ func (s *EmailService) NotifyAdminOfNewUser(user *models.User) error {
|
||||
logger.Error.Print("Couldn't send admin notification mail")
|
||||
return err
|
||||
}
|
||||
return s.SendEmail(config.LoadConfig().SMTP.AdminEmail, subject, body)
|
||||
return s.SendEmail(config.SMTP.AdminEmail, subject, body)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user