-
{ m.Subject }
-
From { m.From }
+
+
{ m.Subject }
+
{ m.From }
-
{ m.Date }
+
{ m.Date.Format("3:04 PM") }
}
diff --git a/cmd/web_server/index.templ b/cmd/web_server/index.templ
index 4c403a6..67165e3 100644
--- a/cmd/web_server/index.templ
+++ b/cmd/web_server/index.templ
@@ -8,15 +8,16 @@ templ index_page() {
nthmail.xyz
+ @styles()
-
+
nthmail.xyz
A disposable, temporary and private mail address!
-
+
}
diff --git a/cmd/web_server/mail.templ b/cmd/web_server/mail.templ
index da59566..5a6fedc 100644
--- a/cmd/web_server/mail.templ
+++ b/cmd/web_server/mail.templ
@@ -13,12 +13,24 @@ templ mail_body_comp(rcpt_addr string, m mail_utils.Mail_obj) {
nthmail.xyz
+ @styles()
-
-
- {m.Subject}
- {m.From}
-
+
+ @header(rcpt_addr)
+
@mime_type(m.Body[m.PreferedBodyIndex])
@@ -40,16 +52,21 @@ templ mime_type(b mail_utils.Mail_body) {
}
templ body_plain(s string) {
-
{ s }
+
}
templ body_html(s string) {
-
+
@templ.Raw(s)
-
+
}
templ body_markdown(s string) {
- @body_html(string(blackfriday.Run([]byte(s))))
- )
+
+ { string(blackfriday.Run([]byte(s))) }
+
}
diff --git a/cmd/web_server/main.go b/cmd/web_server/main.go
index adb7e86..aa0f401 100644
--- a/cmd/web_server/main.go
+++ b/cmd/web_server/main.go
@@ -7,6 +7,7 @@ import (
"net/http"
"os"
"strconv"
+ "time"
"github.com/GRFreire/nthmail/pkg/mail_utils"
"github.com/GRFreire/nthmail/pkg/rig"
@@ -133,6 +134,7 @@ func (sr ServerResouces) handleInbox(res http.ResponseWriter, req *http.Request)
}
mail_obj, err := mail_utils.Parse_mail(m.Data, true)
+ mail_obj.Date = time.Unix(m.Arrived_at, 0)
mail_obj.Id = m.Id
if err != nil {
res.WriteHeader(500)
@@ -198,6 +200,7 @@ func (sr ServerResouces) handleMail(res http.ResponseWriter, req *http.Request)
}
mail_obj, err := mail_utils.Parse_mail(m.Data, false)
+ mail_obj.Date = time.Unix(m.Arrived_at, 0)
mail_obj.Id = m.Id
if err != nil {
res.WriteHeader(500)
diff --git a/cmd/web_server/styles.templ b/cmd/web_server/styles.templ
new file mode 100644
index 0000000..c93e368
--- /dev/null
+++ b/cmd/web_server/styles.templ
@@ -0,0 +1,236 @@
+package main
+
+templ styles() {
+
+}
diff --git a/pkg/mail_utils/mail_utils.go b/pkg/mail_utils/mail_utils.go
index 38de32c..f0687b3 100644
--- a/pkg/mail_utils/mail_utils.go
+++ b/pkg/mail_utils/mail_utils.go
@@ -11,6 +11,7 @@ import (
"net/mail"
"slices"
"strings"
+ "time"
)
type MIMEType uint8
@@ -36,7 +37,7 @@ type Mail_body struct {
type Mail_obj struct {
Id int
From string
- Date string
+ Date time.Time
To string
Bcc string
Subject string
@@ -78,7 +79,6 @@ func Parse_mail(m_data []byte, header_only bool) (Mail_obj, error) {
// HEADERS
dec := new(mime.WordDecoder)
m.From, _ = dec.DecodeHeader(mail_msg.Header.Get("From"))
- m.Date, _ = dec.DecodeHeader(mail_msg.Header.Get("Date"))
m.To, _ = dec.DecodeHeader(mail_msg.Header.Get("To"))
m.Bcc, _ = dec.DecodeHeader(mail_msg.Header.Get("Bcc"))
m.Subject, _ = dec.DecodeHeader(mail_msg.Header.Get("Subject"))