Skip to content

Templates Support

Compare
Choose a tag to compare
@twof twof released this 03 Aug 16:00
· 45 commits to master since this release
08d8921

Thanks to @saicu for the implementation!
https://documentation.mailgun.com/en/latest/user_manual.html#templates

Sending templated emails

let message = Mailgun.TemplateMessage(
    from: "[email protected]",
    to: "[email protected]",
    subject: "Newsletter",
    template: "my-template",
    templateData: ["foo": "bar"]
)

let mailgun = try req.make(Mailgun.self)
return try mailgun.send(message, on: req)

Setting up email templates

let template = Mailgun.Template(name: "my-template", description: "api created :)", template: "<h1>Hello {{ name }}</h1>")
    
let mailgun = try req.make(Mailgun.self)
return try mailgun.createTemplate(template, on: req)