Attachment
public struct Attachment
extension Attachment: Equatable
Represents a Mail‘s attachment.
Different SMTP servers have different attachment size limits.
-
Initialize a data
Attachment.Declaration
Swift
public init(data: Data, mime: String, name: String, inline: Bool = false, additionalHeaders: [String: String] = [:], relatedAttachments: [Attachment] = [])Parameters
dataRaw data to be sent as attachment.
mimeMIME type of the data.
nameFile name which will be presented in the mail.
inlineIndicates if attachment is inline. To embed the attachment in mail content, set to
true. To send as standalone attachment, set tofalse. Defaults tofalse.additionalHeadersAdditional headers for the
Mail. Header keys are capitalized and duplicate keys will overwrite each other. Defaults to none. The following will be ignored: CONTENT-TYPE, CONTENT-DISPOSITION, CONTENT-TRANSFER-ENCODING.relatedRelated
Attachments of this attachment. Defaults to none. -
Initialize an
Attachmentfrom a local file.Declaration
Swift
public init(filePath: String, mime: String = "application/octet-stream", name: String? = nil, inline: Bool = false, additionalHeaders: [String: String] = [:], relatedAttachments: [Attachment] = [])Parameters
filePathPath to the local file.
mimeMIME type of the file. Defaults to
application/octet-stream.nameName of the file. Defaults to the name component in its file path.
inlineIndicates if attachment is inline. To embed the attachment in mail content, set to
true. To send as standalone attachment, set tofalse. Defaults tofalse.additionalHeadersAdditional headers for the attachment. Header keys are capitalized and duplicate keys will replace each other. Defaults to none.
relatedRelated
Attachments of this attachment. Defaults to none. -
Initialize an HTML
Attachment.Declaration
Swift
public init(htmlContent: String, characterSet: String = "utf-8", alternative: Bool = true, additionalHeaders: [String: String] = [:], relatedAttachments: [Attachment] = [])Parameters
htmlContentContent string of HTML.
characterSetCharacter encoding of
htmlContent. Defaults toutf-8.alternativeWhether the HTML is an alternative for plain text or not. Defaults to
true.additionalHeadersAdditional headers for the attachment. Header keys are capitalized and duplicate keys will replace each other. Defaults to none.
relatedRelated
Attachments of this attachment. Defaults to none. -
Returns
trueif theAttachments are equal.Declaration
Swift
public static func == (lhs: Attachment, rhs: Attachment) -> Bool
View on GitHub
Attachment Structure Reference