-
-
Notifications
You must be signed in to change notification settings - Fork 19
feat(imap): integrate MIME into IMAP-SMTP #191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
toddheasley
merged 6 commits into
thunderbird:main
from
toddheasley:feature-imap-integrate-mime
Jan 15, 2026
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
59d8dbc
feat(imap): make MIME types Sendable
toddheasley a1ba06b
feat(imap): IMAP, SMTP integrate MIME
toddheasley daff7c2
Merge remote-tracking branch 'upstream/main' into feature-imap-integr…
toddheasley 7fe3397
feat(imap): refactor IMAP and SMPT logging handlers
toddheasley 8efd6f4
Merge remote-tracking branch 'upstream/main' into feature-imap-integr…
toddheasley a0ca894
fix: remove stray print statements
toddheasley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| /// ``IMAPClient`` throws `IMAPError`. | ||
| public enum IMAPError: Error, CustomStringConvertible, Equatable { | ||
| case underlying(String) | ||
| case example | ||
|
|
||
| init(_ error: Error) { | ||
| self = error as? Self ?? .underlying(error.localizedDescription) | ||
| } | ||
|
|
||
| // MARK: CustomStringConvertible | ||
| public var description: String { | ||
| switch self { | ||
| case .underlying(let string): "Underlying: \(string)" | ||
| case .example: "Example" | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,48 +1,45 @@ | ||
| import EmailAddress | ||
| import Foundation | ||
| import MIME | ||
| import NIOIMAP | ||
|
|
||
| /// [IMAP message attributes](https://www.ietf.org/rfc/rfc9051.html#section-2.3) | ||
| public struct Message { | ||
| public enum Flag: String, CaseIterable, CustomStringConvertible, Sendable { | ||
| case seen = "\\Seen" | ||
| case answered = "\\Answered" | ||
| case flagged = "\\Flagged" | ||
| case deleted = "\\Deleted" | ||
| case draft = "\\Draft" | ||
| case forwarded = "$Forwarded" | ||
| case mdnSent = "$MDNSent" | ||
| case junk = "$Junk" | ||
| case notJunk = "$NotJunk" | ||
| case phishing = "$Phishing" | ||
| public typealias Flag = NIOIMAPCore.Flag | ||
|
|
||
| // MARK: CustomStringConvertible | ||
| public var description: String { rawValue } | ||
| } | ||
|
|
||
| public let isDeleted: Bool | ||
| public let folderID: Int | ||
| public let uid: String | ||
| public let subject: String | ||
| public let date: Date | ||
| public let body: Body | ||
| public let contentType: ContentType | ||
| public let flags: [Flag] | ||
| public let senderList: String | ||
| public let toList: String | ||
| public let ccList: String | ||
| public let bccList: String | ||
| public let replyToList: String | ||
| public let attachmentCount: Int | ||
| public let internalDate: Date | ||
| public let folderID: Int | ||
| public let inReplyTo: String? | ||
| public let messageID: String | ||
| public let previewType: String | ||
| public let preview: String | ||
| public let mimeType: String | ||
| public let normalizedSubjectHash: Int | ||
| public let isEmpty: Bool | ||
| public let isRead: Bool | ||
| public let isFlagged: Bool | ||
| public let isAnswered: Bool | ||
| public let isForwarded: Bool | ||
| public let messagePartID: Int | ||
| public let encryptionType: String | ||
| public let isNewMessage: Bool | ||
| public let replyTo: String? | ||
| public let size: Int | ||
| public let subject: String | ||
| public let uid: UID | ||
|
|
||
| public var isAnswered: Bool { flags.isAnswered } | ||
| public var isDeleted: Bool { flags.isDeleted } | ||
| public var isDraft: Bool { flags.isDraft } | ||
| public var isEmpty: Bool { body.isEmpty } | ||
| public var isFlagged: Bool { flags.isFlagged } | ||
| public var isForwarded: Bool { flags.isForwarded } | ||
| public var isSeen: Bool { flags.isSeen } | ||
| } | ||
|
|
||
| extension Message.Flag: @retroactive CustomStringConvertible { | ||
|
|
||
| // MARK: CustomStringConvertible | ||
| public var description: String { debugDescription } | ||
| } | ||
|
|
||
| public typealias UID = NIOIMAP.UID | ||
|
|
||
| private extension [Message.Flag] { | ||
| var isAnswered: Bool { contains(.answered) } | ||
| var isDeleted: Bool { contains(.deleted) } | ||
| var isDraft: Bool { contains(.draft) } | ||
| var isFlagged: Bool { contains(.flagged) } | ||
| var isForwarded: Bool { contains(.keyword(.forwarded)) } | ||
| var isSeen: Bool { contains(.seen) } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| import EmailAddress | ||
| import Foundation | ||
| import MIME | ||
| import NIOCore | ||
|
|
||
| enum Request { | ||
|
|
@@ -37,18 +38,16 @@ struct RequestEncoder: MessageToByteEncoder { | |
| case .data: | ||
| out.writeString("DATA") | ||
| case .transferData(let email): | ||
| out.writeString("From: \(email.sender)\(line)") | ||
| out.writeString("To: \(email.recipients.map { $0.description }.joined(separator: " "))\(line)") | ||
| out.writeString("Date: \(email.iso8601Date)\(line)") // "EEE, dd MMM yyyy HH:mm:ss Z" | ||
| out.writeString("Message-ID: \(email.messageID)\(line)") | ||
| out.writeString("Subject: \(email.subject)\(line)") | ||
| // out.writeString("MIME-Version: 1.0\(line)") | ||
| out.writeString("Content-Type: \(email.contentType)\(line)") | ||
| out.writeBytes(email.body) | ||
| out.writeString("\(line).") | ||
| out.writeString("From: \(email.sender)\(crlf)") | ||
| out.writeString("To: \(email.recipients.map { $0.description }.joined(separator: " "))\(crlf)") | ||
| out.writeString("Date: \(email.date.rfc822Format())\(crlf)") | ||
| out.writeString("Message-ID: \(email.messageID)\(crlf)") | ||
| out.writeString("Subject: \(email.subject)\(crlf)") | ||
| out.writeBytes(email.body.rawValue) | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Multipart body and headers already natively data now |
||
| out.writeString("\(crlf).") | ||
| case .quit: | ||
| out.writeString("QUIT") | ||
| } | ||
| out.writeString(line) | ||
| out.writeString(crlf) | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,3 @@ | ||
| import Foundation | ||
| import NIOCore | ||
|
|
||
| enum Response { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Multipart logic moved into
MIMElibrary