Releases: vapor-community/mailgun
Releases · vapor-community/mailgun
Can now attach files
router.post("mail") { (req) -> Future<Response> in
let fm = FileManager.default
guard let attachmentData = fm.contents(atPath: "/tmp/test.pdf") else {
throw Abort(.internalServerError)
}
let attachment = File(data: attachmentData, filename: "test.pdf")
let message = Mailgun.Message(
from: "postmaster@example.com",
to: "example@gmail.com",
subject: "Newsletter",
text: "This is a newsletter",
html: "<h1>This is a newsletter</h1>",
attachments: [attachment]
)
let mailgun = try req.make(Mailgun.self)
return try mailgun.send(message, on: req)
}
Full API key now required
It was pointed out in #11 that some api keys don't begin with key-
so the bit prepending key-
to every request that didn't include it was breaking.
Full api keys are now required to be used.
Mail can be sent with an application in addition to a request
Merge pull request #8 from vkill/patch-1 Make send work on Application
Bug fix
Updated for Vapor 3
No public api changes, but the primary features of Mailgun are supported now
Add Forwarding Setup
public func boot(_ app: Application) throws {
// sets up a catch_all forward for the route listed
let routeSetup = RouteSetup(forwardURL: "http://example.com/mailgun/all", description: "A route for all emails")
let mailgunClient = try app.make(Mailgun.self)
try mailgunClient.setupForwarding(setup: routeSetup, with: app).map { (resp) in
print(resp)
}
}
Added IncomingMailgun
Enables easy decoding of forwarded emails from Mailgun
mailgunGroup.post("all") { (req) -> Future<String> in
do {
return try req.content.decode(IncomingMailgun.self).map { (incomingMail) in
return "Hello"
}
} catch {
throw Abort(HTTPStatus.internalServerError, reason: "Could not decode incoming Mailgun")
}
}
Cleanup
NIO changes
Merge pull request #2 from twof/nio Nio