feat(emailApi): formatting
Build and Push Docker image / build-and-push (push) Successful in 2m7s Details

This commit is contained in:
Valentin Kolb 2024-10-24 22:06:12 +02:00
parent 98c55bc5ae
commit 1af5c40832
2 changed files with 10 additions and 6 deletions

View File

@ -28,6 +28,9 @@ func sendEmailToUser(app *pocketbase.PocketBase, registry *template.Registry, re
recipientEmail := recipient.GetString("email") recipientEmail := recipient.GetString("email")
senderEmail := sender.GetString("email") senderEmail := sender.GetString("email")
// get email subject
subject := "[StuVe IT] " + emailRecord.GetString("subject")
// render email template // render email template
html, err := registry.LoadFiles( html, err := registry.LoadFiles(
"html/blankEmail.html", "html/blankEmail.html",
@ -37,6 +40,7 @@ func sendEmailToUser(app *pocketbase.PocketBase, registry *template.Registry, re
"SENDER_GIVENNAME": sender.GetString("givenName"), "SENDER_GIVENNAME": sender.GetString("givenName"),
"SENDER_EMAIL": senderEmail, "SENDER_EMAIL": senderEmail,
"CONTENT": safeContent, "CONTENT": safeContent,
"SUBJECT": subject,
}) })
if err != nil { if err != nil {
currentErrors := emailRecord.GetString("errors") currentErrors := emailRecord.GetString("errors")
@ -45,9 +49,6 @@ func sendEmailToUser(app *pocketbase.PocketBase, registry *template.Registry, re
return return
} }
// get email subject
subject := emailRecord.GetString("subject")
// set reply-to header // set reply-to header
headers := make(map[string]string) headers := make(map[string]string)
headers["Reply-To"] = senderEmail headers["Reply-To"] = senderEmail
@ -59,7 +60,7 @@ func sendEmailToUser(app *pocketbase.PocketBase, registry *template.Registry, re
Name: app.Settings().Meta.SenderName, Name: app.Settings().Meta.SenderName,
}, },
To: []mail.Address{{Address: recipientEmail}}, To: []mail.Address{{Address: recipientEmail}},
Subject: "[StuVe IT] " + subject, Subject: subject,
HTML: html, HTML: html,
Headers: headers, Headers: headers,
} }

View File

@ -48,15 +48,18 @@
<div class="stack"> <div class="stack">
<div class="container"> <div class="container">
<h1 class="blue-text">You got mail 📩</h1> <h1 class="blue-text">You got mail 📩</h1>
<p>Du hast eine E-Mail von {{.SENDER_GIVENNAME}} {{.SENDER_SN}} ({{.SENDER_EMAIL}})</p> <p>
Du hast eine E-Mail von {{.SENDER_GIVENNAME}} {{.SENDER_SN}} (<a href="mailto:{{.SENDER_EMAIL}}">{{.SENDER_EMAIL}}</a>)
</p>
</div> </div>
<div class="container"> <div class="container">
{{.CONTENT|raw}} {{.CONTENT|raw}}
</div> </div>
<div class="container"> <div class="container">
<p>Du kannst {{.SENDER_GIVENNAME}} {{.SENDER_SN}} antworten, indem du auf den untenstehenden Button klickst.</p> <p>Du kannst {{.SENDER_GIVENNAME}} {{.SENDER_SN}} antworten, indem du auf den untenstehenden Button klickst:</p>
<br/> <br/>
<a class="action-btn" href="mailto:{{.SENDER_EMAIL}}?subject=Re: {{.SUBJECT}}">↩ Antworten</a> <a class="action-btn" href="mailto:{{.SENDER_EMAIL}}?subject=Re: {{.SUBJECT}}">↩ Antworten</a>
<br/>
</div> </div>
<div class="container"> <div class="container">
<div class="group"> <div class="group">