containerized; first fixes; html templates added
This commit is contained in:
@@ -27,10 +27,14 @@ type SMTPConfig struct {
|
||||
Port int `json:"Port"`
|
||||
}
|
||||
|
||||
type TemplateConfig struct {
|
||||
MailDir string `json:"MailDir"`
|
||||
}
|
||||
type Config struct {
|
||||
DB DatabaseConfig `json:"db"`
|
||||
Auth AuthenticationConfig
|
||||
SMTP SMTPConfig `json:"smtp"`
|
||||
DB DatabaseConfig `json:"db"`
|
||||
Auth AuthenticationConfig
|
||||
SMTP SMTPConfig `json:"smtp"`
|
||||
Templates TemplateConfig `json:"templates"`
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
|
||||
func Run() {
|
||||
cfg := config.LoadConfig()
|
||||
|
||||
logger.Info.Printf("Config: %v", cfg)
|
||||
db := database.Connect(cfg.DB)
|
||||
defer db.Close()
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package services
|
||||
|
||||
import (
|
||||
"GoMembership/internal/config"
|
||||
"GoMembership/internal/models"
|
||||
"GoMembership/pkg/logger"
|
||||
"bytes"
|
||||
@@ -33,9 +34,11 @@ func (s *EmailService) SendEmail(to string, subject string, body string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func ParseTemplate(path string, data interface{}) (string, error) {
|
||||
func ParseTemplate(filename string, data interface{}) (string, error) {
|
||||
// Read the email template file
|
||||
tpl, err := template.ParseFiles(path)
|
||||
|
||||
templateDir := config.LoadConfig().Templates.MailDir
|
||||
tpl, err := template.ParseFiles(templateDir + "/" + filename)
|
||||
if err != nil {
|
||||
logger.Error.Printf("Failed to parse email template: %v", err)
|
||||
return "", err
|
||||
@@ -51,7 +54,6 @@ func ParseTemplate(path string, data interface{}) (string, error) {
|
||||
return tplBuffer.String(), nil
|
||||
}
|
||||
func (s *EmailService) SendWelcomeEmail(user models.User) error {
|
||||
|
||||
// Prepare data to be injected into the template
|
||||
data := struct {
|
||||
FirstName string
|
||||
@@ -62,7 +64,7 @@ func (s *EmailService) SendWelcomeEmail(user models.User) error {
|
||||
}
|
||||
|
||||
subject := "Willkommen beim Dörpsmobil Hasloh e.V."
|
||||
body, err := ParseTemplate("internal/templates/mail_welcome.html", data)
|
||||
body, err := ParseTemplate("mail_welcome.html", data)
|
||||
if err != nil {
|
||||
logger.Error.Print("Couldn't send welcome mail")
|
||||
return err
|
||||
|
||||
67
internal/templates/mail_newRegistration.html
Normal file
67
internal/templates/mail_newRegistration.html
Normal file
@@ -0,0 +1,67 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Willkommen beim Dörpsmobil Hasloh e.V.</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
line-height: 1.6;
|
||||
color: #333;
|
||||
margin: 0;
|
||||
padding: 20px;
|
||||
background-color: #f9f9f9;
|
||||
}
|
||||
.container {
|
||||
max-width: 600px;
|
||||
margin: 0 auto;
|
||||
padding: 20px;
|
||||
background-color: #fff;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 8px;
|
||||
}
|
||||
h1 {
|
||||
color: #007b5e;
|
||||
}
|
||||
p {
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
.contact-info {
|
||||
margin-top: 20px;
|
||||
}
|
||||
.contact-info strong {
|
||||
display: block;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
a {
|
||||
color: #007b5e;
|
||||
text-decoration: none;
|
||||
}
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>{{.Firstname}} {{.LastName}} hat sich registriert</h1>
|
||||
<p>Ein neues Vereinsmitglied hat sich registriert</p>
|
||||
<p>{{.Firstname}} {{.LastName}} hat sich registriert. Hier sind die Daten:</p>
|
||||
<br>
|
||||
<div class="contact-info">
|
||||
<strong>Registrierungsdaten:</strong>
|
||||
Name: {{.Firstname}} {{.LastName}} <br>
|
||||
Email: {{.Email}}<br>
|
||||
IBAN: {{.IBAN}}<br>
|
||||
BIC: {{.BIC}}<br>
|
||||
Mandatsreferenz: {{.MandateReference}}<br>
|
||||
</div>
|
||||
<p>Mit freundlichen Grüßen,<br>
|
||||
der Server
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
67
internal/templates/mail_welcome.html
Normal file
67
internal/templates/mail_welcome.html
Normal file
@@ -0,0 +1,67 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Willkommen beim Dörpsmobil Hasloh e.V.</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
line-height: 1.6;
|
||||
color: #333;
|
||||
margin: 0;
|
||||
padding: 20px;
|
||||
background-color: #f9f9f9;
|
||||
}
|
||||
.container {
|
||||
max-width: 600px;
|
||||
margin: 0 auto;
|
||||
padding: 20px;
|
||||
background-color: #fff;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 8px;
|
||||
}
|
||||
h1 {
|
||||
color: #007b5e;
|
||||
}
|
||||
p {
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
.contact-info {
|
||||
margin-top: 20px;
|
||||
}
|
||||
.contact-info strong {
|
||||
display: block;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
a {
|
||||
color: #007b5e;
|
||||
text-decoration: none;
|
||||
}
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>Willkommen beim Dörpsmobil Hasloh e.V.</h1>
|
||||
<p>Hallo {{.FirstName}},</p>
|
||||
<p>herzlich willkommen beim Dörpsmobil Hasloh e.V.! Vielen Dank für Ihre Registrierung und Ihre Unterstützung unseres Projekts.</p>
|
||||
<p>Wir freuen uns, Sie als Mitglied begrüßen zu dürfen und wünschen Ihnen stets eine sichere und angenehme Fahrt mit unseren Fahrzeugen.</p>
|
||||
<p>Für weitere Fragen stehen wir Ihnen gerne zur Verfügung:</p>
|
||||
<div class="contact-info">
|
||||
<strong>Kontakt:</strong>
|
||||
Name: Anke Freitag<br>
|
||||
Vorsitzende Doerpsmobil-Hasloh e.V.<br>
|
||||
E-Mail: <a href="mailto:info@doerpsmobil-hasloh.de">info@doerpsmobil-hasloh.de</a><br>
|
||||
Telefon: +49 174 870 1392
|
||||
</div>
|
||||
<p>Besuchen Sie auch unsere Webseite unter <a href="https://carsharing-hasloh.de">https://carsharing-hasloh.de</a> für weitere Informationen.</p>
|
||||
<p>Mit freundlichen Grüßen,<br>
|
||||
Ihr Team von Dörpsmobil Hasloh e.V.
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user