Skip to content

Conversation

LinusGeffarth
Copy link
Contributor

@LinusGeffarth LinusGeffarth commented May 8, 2020

Example usage with a pdf file from the Public folder:

let directory = DirectoryConfig.detect()
let configDir = "Public/storage/pdf"
let pdfData = try Data(contentsOf: URL(fileURLWithPath: directory.workDir)
    .appendingPathComponent(configDir, isDirectory: true)
    .appendingPathComponent(some.pdf, isDirectory: false))

let attachments: [Attachment] = [
    Attachment(data: pdfData, mime: "application/pdf", name: "some.pdf", inline: false)
]
return try req.view().render("my-template").map { (view) -> [Mailer.Message] in
    return users.map { user in
        return Mailer.Message(
            from: "[email protected]",
            to: "[email protected]",
            subject: "Example subject", text: "Example subject",
            html: String(data: view.data, encoding: .utf8) ?? "",
            attachments: attachments
        )
    }
}

Again, additions only, shouldn't break anything.

@rafiki270
Copy link
Contributor

Would you mind updating the documentation please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants