Skip to content

Commit

Permalink
Merge pull request #32 from Captain-Kirkie/feat/add-contentID
Browse files Browse the repository at this point in the history
feat: contentID for email attachments
  • Loading branch information
mczachurski authored Sep 9, 2024
2 parents 13c9275 + 422583d commit 152b52c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Sources/Smtp/Models/Attachment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ public struct Attachment {
public let name: String
public let contentType: String
public let data: Data
public let contentID: String?

public init(name: String, contentType: String, data: Data) {
public init(name: String, contentType: String, data: Data, contentID: String? = nil) {
self.name = name
self.contentType = contentType
self.data = data
self.contentID = contentID
}
}
3 changes: 3 additions & 0 deletions Sources/Smtp/Models/Email.swift
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ extension Email {
for (index, attachment) in self.attachments.enumerated() {
out.writeString("Content-type: \(attachment.contentType)\r\n")
out.writeString("Content-Transfer-Encoding: base64\r\n")
if let contentID = attachment.contentID {
out.writeString("Content-ID: \(contentID)\r\n")
}
out.writeString("Content-Disposition: attachment; filename=\"\(attachment.name)\"\r\n\r\n")
out.writeString("\(attachment.data.base64EncodedString())\r\n")

Expand Down

0 comments on commit 152b52c

Please sign in to comment.