feat: better handling of oversized mails, and add junk option

This commit is contained in:
2025-11-13 11:11:53 +01:00
parent 6de059dca7
commit b7e4c8d6ac
4 changed files with 82 additions and 27 deletions

View File

@@ -266,7 +266,7 @@ func (ic *IMAPClient) SaveDraft(email Email, response string) (err error) {
email.From,
email.Subject,
email.Date.Format("Mon, 02 Jan 2006 15:04:05 -0700"),
extractMessageContent(email.Body))
ExtractMessageContent(email.Body))
literal := &MessageLiteral{
content: []byte(draft),
@@ -287,9 +287,9 @@ func (ic *IMAPClient) SaveDraft(email Email, response string) (err error) {
return nil
}
// extractMessageContent attempts to extract just the message content
// ExtractMessageContent attempts to extract just the message content
// by removing email headers and MIME boundaries
func extractMessageContent(body string) string {
func ExtractMessageContent(body string) string {
logger.WithField("bodyLength", len(body)).Debug("Starting message content extraction")
logger.WithField("rawInputBody", body).Debug("extractMessageContent: Raw input body")
msg, err := mail.ReadMessage(strings.NewReader(body))