Skip to content

Commit 152b52c

Browse files
authored
Merge pull request #32 from Captain-Kirkie/feat/add-contentID
feat: contentID for email attachments
2 parents 13c9275 + 422583d commit 152b52c

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

Sources/Smtp/Models/Attachment.swift

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ public struct Attachment {
1010
public let name: String
1111
public let contentType: String
1212
public let data: Data
13+
public let contentID: String?
1314

14-
public init(name: String, contentType: String, data: Data) {
15+
public init(name: String, contentType: String, data: Data, contentID: String? = nil) {
1516
self.name = name
1617
self.contentType = contentType
1718
self.data = data
19+
self.contentID = contentID
1820
}
1921
}

Sources/Smtp/Models/Email.swift

+3
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ extension Email {
135135
for (index, attachment) in self.attachments.enumerated() {
136136
out.writeString("Content-type: \(attachment.contentType)\r\n")
137137
out.writeString("Content-Transfer-Encoding: base64\r\n")
138+
if let contentID = attachment.contentID {
139+
out.writeString("Content-ID: \(contentID)\r\n")
140+
}
138141
out.writeString("Content-Disposition: attachment; filename=\"\(attachment.name)\"\r\n\r\n")
139142
out.writeString("\(attachment.data.base64EncodedString())\r\n")
140143

0 commit comments

Comments
 (0)