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
data
Raw data to be sent as attachment.
mime
MIME type of the data.
name
File name which will be presented in the mail.
inline
Indicates if attachment is inline. To embed the attachment in mail content, set to
true
. To send as standalone attachment, set tofalse
. Defaults tofalse
.additionalHeaders
Additional 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.related
Related
Attachment
s of this attachment. Defaults to none. -
Initialize an
Attachment
from 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
filePath
Path to the local file.
mime
MIME type of the file. Defaults to
application/octet-stream
.name
Name of the file. Defaults to the name component in its file path.
inline
Indicates if attachment is inline. To embed the attachment in mail content, set to
true
. To send as standalone attachment, set tofalse
. Defaults tofalse
.additionalHeaders
Additional headers for the attachment. Header keys are capitalized and duplicate keys will replace each other. Defaults to none.
related
Related
Attachment
s 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
htmlContent
Content string of HTML.
characterSet
Character encoding of
htmlContent
. Defaults toutf-8
.alternative
Whether the HTML is an alternative for plain text or not. Defaults to
true
.additionalHeaders
Additional headers for the attachment. Header keys are capitalized and duplicate keys will replace each other. Defaults to none.
related
Related
Attachment
s of this attachment. Defaults to none. -
Returns
true
if theAttachment
s are equal.Declaration
Swift
public static func == (lhs: Attachment, rhs: Attachment) -> Bool