diff --git a/Sources/Smtp/Models/Attachment.swift b/Sources/Smtp/Models/Attachment.swift index 01af71b..cfcaa07 100644 --- a/Sources/Smtp/Models/Attachment.swift +++ b/Sources/Smtp/Models/Attachment.swift @@ -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 } } diff --git a/Sources/Smtp/Models/Email.swift b/Sources/Smtp/Models/Email.swift index ba1efe9..ee47cae 100644 --- a/Sources/Smtp/Models/Email.swift +++ b/Sources/Smtp/Models/Email.swift @@ -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")