MailCore
MailCore copied to clipboard
Send attachments with SMTP
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.
Would you mind updating the documentation please?