diff --git a/internal/smtp/gui.html b/internal/smtp/gui.html index 8107a38..673055e 100644 --- a/internal/smtp/gui.html +++ b/internal/smtp/gui.html @@ -45,6 +45,11 @@
+
+ Raw Message:
+ Download
+
Body:
Show
@@ -70,6 +75,7 @@
const msgmeta = document.getElementById("msgmeta")
const multimeta = document.getElementById("multimeta")
const partlist = document.getElementById("partlist")
+const rawlink = document.getElementById("rawlink")
let n_received = 0
let index = {"count": 0, "messages": []}
@@ -103,6 +109,7 @@
msgmeta.textContent = JSON.stringify(metadata, null, 2)
bodylink.href = `${prefix}/${idx}/body`
+ rawlink.href = `${prefix}/${idx}/raw`
partlist.innerHTML=""
diff --git a/internal/smtp/http.go b/internal/smtp/http.go
index 3b8c8ca..0adaa8d 100644
--- a/internal/smtp/http.go
+++ b/internal/smtp/http.go
@@ -77,6 +77,9 @@ func (h *smtpHTTPHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
case "multipart":
h.handleMultipartIndex(w, r, idx)
return
+ case "raw":
+ h.handleRawMessageData(w, r, idx)
+ return
}
case 3, 4:
if pathParts[1] == "multipart" {
@@ -247,6 +250,17 @@ func (h *smtpHTTPHandler) handleMultipartBody(
w.Write(part.Body())
}
+func (h *smtpHTTPHandler) handleRawMessageData(w http.ResponseWriter, r *http.Request, idx int) {
+ msg := h.retrieveMessage(w, idx)
+ if msg == nil {
+ return
+ }
+
+ w.Header().Set("Content-Type", "message/rfc822")
+
+ w.Write(msg.RawMessageData())
+}
+
// retrieveMessage tries to retrieve the ReceivedMessage with the given index.
// If found, returns the message. If not found, responds with Status 404
// and returns nil.