Parameters

struct Parameters : Encodable, EmailHeaderRepresentable, Scheduling, Validatable

The Email.Parameters struct serves as the parameters sent on the email send API.

  • An array of personalization instances representing the various recipients of the email.

    Declaration

    Swift

    public var personalizations: [Personalization]
  • The content sections of the email.

    Declaration

    Swift

    public var content: [Content]?
  • The subject of the email. If the personalizations in the email contain subjects, those will override this subject.

    Declaration

    Swift

    public var subject: String?
  • The sending address on the email.

    Declaration

    Swift

    public var from: Address
  • The reply to address on the email.

    Declaration

    Swift

    public var replyTo: Address?
  • Attachments to add to the email.

    Declaration

    Swift

    public var attachments: [Attachment]?
  • The ID of a template from the Template Engine to use with the email.

    Declaration

    Swift

    public var templateID: String?
  • Additional headers that should be added to the email.

    Declaration

    Swift

    public var headers: [String : String]?
  • Categories to associate with the email.

    Declaration

    Swift

    public var categories: [String]?
  • A dictionary of key/value pairs that define large blocks of content that can be inserted into your emails using substitution tags. An example of this might look like the following:

    let bob = Personalization(recipients: "bob@example.com")
    bob.substitutions = [
        ":salutation": ":male",
        ":name": "Bob",
        ":event_details": ":event2",
        ":event_date": "Feb 14"
    ]
    
    let alice = Personalization(recipients: "alice@example.com")
    alice.substitutions = [
        ":salutation": ":female",
        ":name": "Alice",
        ":event_details": ":event1",
        ":event_date": "Jan 1"
    ]
    
    let casey = Personalization(recipients: "casey@example.com")
    casey.substitutions = [
        ":salutation": ":neutral",
        ":name": "Casey",
        ":event_details": ":event1",
        ":event_date": "Aug 11"
    ]
    
    let personalization = [
        bob,
        alice,
        casey
    ]
    let plainText = ":salutation,\n\nPlease join us for the :event_details."
    let htmlText = "<p>:salutation,</p><p>Please join us for the :event_details.</p>"
    let content = Content.emailBody(plain: plainText, html: htmlText)
    let email = Email(
        personalizations: personalization,
        from: "from@example.com",
        content: content
    )
    email.parameters?.subject = "Hello World"
    email.parameters?.sections = [
        ":male": "Mr. :name",
        ":female": "Ms. :name",
        ":neutral": ":name",
        ":event1": "New User Event on :event_date",
        ":event2": "Veteran User Appreciation on :event_date"
    ]
    

    Declaration

    Swift

    public var sections: [String : String]?
  • A set of custom arguments to add to the email. The keys of the dictionary should be the names of the custom arguments, while the values should represent the value of each custom argument. If personalizations in the email also contain custom arguments, they will be merged with these custom arguments, taking a preference to the personalization’s custom arguments in the case of a conflict.

    Declaration

    Swift

    public var customArguments: [String : String]?
  • asm

    An ASM instance representing the unsubscribe group settings to apply to the email.

    Declaration

    Swift

    public var asm: ASM?
  • An optional time to send the email at.

    Declaration

    Swift

    public var sendAt: Date?
  • This ID represents a batch of emails (AKA multiple sends of the same email) to be associated to each other for scheduling. Including a batch_id in your request allows you to include this email in that batch, and also enables you to cancel or pause the delivery of that entire batch. For more information, please read about Cancel Scheduled Sends.

    Declaration

    Swift

    public var batchID: String?
  • The IP Pool that you would like to send this email from. See the docs page for more information about creating IP Pools.

    Declaration

    Swift

    public var ipPoolName: String?
  • An optional array of mail settings to configure the email with.

    Declaration

    Swift

    public var mailSettings: MailSettings
  • An optional array of tracking settings to configure the email with.

    Declaration

    Swift

    public var trackingSettings: TrackingSettings
  • Initializes the parameters with a list of personalizations, a from address, content, and a subject.

    Declaration

    Swift

    public init(personalizations: [Personalization], from: Address, content: [Content]? = nil, templateID: String? = nil, subject: String? = nil)

    Parameters

    personalizations

    An array of personalization instances.

    from

    A from address to use in the email.

    content

    An array of content instances to use in the body.

    subject

    An optional global subject line.