Mail

public struct Mail

Represents an email. It contains necessary information like from, to and text with which Hedwig could send it with a connection to some SMTP server. The whole type is immutable. You need to create a mail through the initialzer and then feed it to a Hedwig instance to send.

  • From name and address.

    Declaration

    Swift

    public let from: NameAddressPair?
  • to

    To names and addresses.

    Declaration

    Swift

    public let to: [NameAddressPair]
  • cc

    Carbon copy (Cc) names and addresses.

    Declaration

    Swift

    public let cc: [NameAddressPair]?
  • bcc

    Blind carbon copy (Bcc) names and addresses.

    Declaration

    Swift

    public let bcc: [NameAddressPair]?
  • The title of current email.

    Declaration

    Swift

    public let subject: String
  • The text content of current email.

    Declaration

    Swift

    public let text: String
  • The attachements contained in the email.

    Declaration

    Swift

    public let attachments: [Attachment]
  • The additional headers will be presented in the mail header.

    Declaration

    Swift

    public let additionalHeaders: [String: String]
  • The alternative attachement. The last alternative attachment in attachments will be the alternative attachement of the whole Mail.

    Declaration

    Swift

    public let alternative: Attachment?
  • Message id. It is a UUID string appeneded by .Hedwig.

    Declaration

    Swift

    public let messageId = UUID().uuidString + ".Hedwig"
  • Creating date of the mail.

    Declaration

    Swift

    public let date = Date()
  • Initilize an email.

    Note

    Note:

    • The from, to, cc and bcc parameters accept a email specified string as input. Hedwig will try to parse the string and get email addresses. You can find supported string format here.
    • If you need to customize the mail header field, pass it with additionalHeaders.

    Declaration

    Swift

    public init(text: String,
             from: String,
             to: String,
             cc: String? = nil,
             bcc: String? = nil,
             subject: String = "",
             attachments: [Attachment]? = nil,
             additionalHeaders: [String: String] = [:])

    Parameters

    text

    The plain text of the mail.

    from

    From name and address.

    to

    To names and addresses.

    cc

    Carbon copy (Cc) names and addresses. Default is nil.

    bcc

    Blind carbon copy (Bcc) names and addresses. Default is nil.

    subject

    Subject (title) of the email. Default is empty string.

    attachments

    Attachements of the mail.

    additionalHeaders

    Additional headers when sending the mail.