aboutsummaryrefslogtreecommitdiffstats
path: root/worker/imap/imap.go
diff options
context:
space:
mode:
Diffstat (limited to 'worker/imap/imap.go')
-rw-r--r--worker/imap/imap.go15
1 files changed, 8 insertions, 7 deletions
diff --git a/worker/imap/imap.go b/worker/imap/imap.go
index 67d56264..9b6316b5 100644
--- a/worker/imap/imap.go
+++ b/worker/imap/imap.go
@@ -50,11 +50,6 @@ func translateEnvelope(e *imap.Envelope) *models.Envelope {
return nil
}
- // we strip the msgid of "<>" in order to be more compatible with go-message
- // which wants to handle msgids without the markers
- msgID := strings.TrimSuffix(strings.TrimPrefix(e.MessageId, "<"), ">")
- inReplyTo := strings.TrimSuffix(strings.TrimPrefix(e.InReplyTo, "<"), ">")
-
return &models.Envelope{
Date: e.Date,
Subject: e.Subject,
@@ -63,11 +58,17 @@ func translateEnvelope(e *imap.Envelope) *models.Envelope {
To: translateAddresses(e.To),
Cc: translateAddresses(e.Cc),
Bcc: translateAddresses(e.Bcc),
- MessageId: msgID,
- InReplyTo: inReplyTo,
+ MessageId: translateMessageID(e.MessageId),
+ InReplyTo: translateMessageID(e.InReplyTo),
}
}
+func translateMessageID(messageID string) string {
+ // Strip away unwanted characters, go-message expects the message id
+ // without brackets, spaces, tabs and new lines.
+ return strings.Trim(messageID, "<> \t\r\n")
+}
+
func translateAddresses(addrs []*imap.Address) []*mail.Address {
var converted []*mail.Address
for _, addr := range addrs {