func handleMail(msg *imap.MsgPart) (parts *MessagePart) { parts = &MessagePart{ID: msg.ID, Name: msg.Name, Type: msg.Type} switch msg.Type { case "text/plain": parts.Contents = string(msg.Text()) case "text/html": parts.Contents, _ = redactomat.RedactString(string(msg.Text())) case "multipart/alternative": parts.Children = handleAlternative(msg) case "multipart/mixed": parts.Children = handleMixed(msg) } return parts }