Attachment
public struct Attachment
Presentation an attachement contained in a Mail
.
-
Properties when the attachment is a file.
See moreDeclaration
Swift
public struct FileProperty
-
Properties when the attachment is an HTML string.
See moreDeclaration
Swift
public struct HTMLProperty
-
Properties when the attachment is some raw data.
See moreDeclaration
Swift
public struct DataProperty
-
Attachment type.
- file: The attachment is a file in local disk.
- html: The attachment is an HTML string.
- data: The attachment is some raw data.
Declaration
Swift
public enum AttachmentType
-
The type of current attachment.
Declaration
Swift
public let type: AttachmentType
-
Additional headers when sending current attachment with a
Mail
.Declaration
Swift
public let additionalHeaders: [String: String]
-
Related attachments of current attachment. The
related
ones will be contained in arelated
boundary in the mail body.Declaration
Swift
public let related: [Attachment]
-
Whether this attachment is an alternative one.
Declaration
Swift
public var isAlternative: Bool
-
Initilize a file attachment.
Declaration
Swift
public init(filePath: String, mime: String? = nil, name: String? = nil, inline: Bool = false, additionalHeaders: [String: String] = [:], related: [Attachment] = [])
Parameters
filePath
Path in the local disk of the file.
mime
MIME type of the file. Default is
nil
, which means leave to Hedwig to guess the type from file extension. If Hedwig can not determine the MIME type, a general binary typeapplication/octet-stream
will be used.name
File name which will be presented in the mail. Default is the file name from
filePath
.inline
Whether the file could be inline or not. When set to
true
, the attachment “Content-Disposition” header will beinline
, otherwise it will beattachment
. If you want to embed the file in mail content, set it totrue
. Otherwise if you need it to be a standalone attachment,false
.additionalHeaders
Additional headers when sending current attachment with a
Mail
.related
Related attachments of current attachment. The
related
ones will be contained in arelated
boundary in the mail body. -
Initilize a data attachment.
Declaration
Swift
public init(data: Data, mime: String, name: String, inline: Bool = false, additionalHeaders: [String: String] = [:], related: [Attachment] = [])
Parameters
data
Raw data will be sent as attachment.
mime
MIME type of the data.
name
File name which will be presented in the mail.
inline
Whether the file could be inline or not. When set to
true
, the attachment “Content-Disposition” header will beinline
, otherwise it will beattachment
. If you want to embed the file in mail content, set it totrue
. Otherwise if you need it to be a standalone attachment,false
.additionalHeaders
Additional headers when sending current attachment with a
Mail
.related
Related attachments of current attachment. The
related
ones will be contained in arelated
boundary in the mail body. -
Initilize an HTML attachment.
Declaration
Swift
public init(htmlContent: String, characterSet: String = "utf-8", alternative: Bool = true, inline: Bool = true, additionalHeaders: [String: String] = [:], related: [Attachment] = [])
Parameters
htmlContent
Content string of HTML.
characterSet
Charater encoding set of
htmlContent
. Default isutf-8
.alternative
Whether this HTML could be alternative for plain text. Default is
true
, means the HTML content could be alternative for plain text.inline
Whether the HTML could be inline or not. Default is
true
.additionalHeaders
Additional headers when sending current attachment with a
Mail
.related
Related attachments of current attachment. The
related
ones will be contained in arelated
boundary in the mail body. -
Initilize an attachment with an
AttachmentType
.Declaration
Swift
public init(type: AttachmentType, additionalHeaders: [String: String] = [:], related: [Attachment] = [])
Parameters
type
The type of attachement.
additionalHeaders
Additional headers when sending current attachment with a
Mail
.related
Related attachments of current attachment. The
related
ones will be contained in arelated
boundary in the mail body.
-
Whether two
Attachment.FileProperty
should equal. TwoAttachment.FileProperty
will equal to each other when all members equal.Declaration
Swift
public static func ==(lhs: Attachment.FileProperty, rhs: Attachment.FileProperty) -> Bool
Parameters
lhs
Left hand
FileProperty
.rhs
Right hand
FileProperty
Return Value
true
if two file properties equal. Otherwise,false
.
-
Whether two
Attachment.DataProperty
should equal. TwoAttachment.DataProperty
will equal to each other when all members equal.Declaration
Swift
public static func ==(lhs: Attachment.DataProperty, rhs: Attachment.DataProperty) -> Bool
Parameters
lhs
Left hand
DataProperty
.rhs
Right hand
DataProperty
Return Value
true
if two data properties equal. Otherwise,false
.
-
Whether two
Attachment.HTMLProperty
should equal. TwoAttachment.HTMLProperty
will equal to each other when all members equal.Declaration
Swift
public static func ==(lhs: Attachment.HTMLProperty, rhs: Attachment.HTMLProperty) -> Bool
Parameters
lhs
Left hand
HTMLProperty
.rhs
Right hand
HTMLProperty
Return Value
true
if two HTML properties equal. Otherwise,false
.
-
Whether two
Attachment
should equal. TwoAttachment
will equal to each other when all members equal.Declaration
Swift
public static func ==(lhs: Attachment, rhs: Attachment) -> Bool
Parameters
lhs
Left hand
Attachment
.rhs
Right hand
Attachment
Return Value
true
if two attachments equal. Otherwise,false
.