Releases: vapor-community/mailgun
Mailgun 5.0.0
This release of mailgun allows a user to mock MailgunProvider
for testing and also uses the correct EventLoop
for Request
extension Application.Mailgun.Provider {
static var fake: Self {
.init {
$0.mailgun.use { app, _ in
MockMailgun(eventLoop: app.eventLoopGroup.next())
}
}
}
}
This release also renames the package name and url to be more concise.
So now installing mailgun will look like
.package(url: "https://github.com/vapor-community/mailgun.git", from: "5.0.0")
.target(name: "App", dependencies: [
.product(name: "Vapor", package: "vapor"),
.product(name: "Mailgun", package: "mailgun")
])
Swift 5.2, Vapor 4 RC and Bug Fixes
Merge pull request #39 from MihaelIsaev/master Fix `IncomingMessage` model and update to Vapor4 RC with Swift 5.2
Vapor 4 support
Mailgun now supports Vapor 4! Development for Vapor 4 will be done on master
from here on out and Vapor 3 development will be done on the vapor3
branch.
import Mailgun
// Called before your application initializes.
func configure(_ app: Application) throws {
/// case 1
/// put into your environment variables the following keys:
/// MAILGUN_API_KEY=...
app.mailgun.configuration = .environment
/// case 2
/// manually
app.mailgun.configuration = .init(apiKey: "<api key>")
}
// call it without arguments to use default domain
app.mailgun().send(...)
req.mailgun().send(...)
// or call it with domain
app.mailgun(.myApp1).send(...)
req.mailgun(.myApp1).send(...)
Support Multiple Domains
You can now use multiple domains to send emails with Mailgun
let mailgun = Mailgun(apiKey: "<api key>")
services.register(mailgun, as: Mailgun.self)
// Put this extension at the bottom or create a new file for it
extension Mailgun.DomainConfig {
static var euDomain: Mailgun.DomainConfig {
return Mailgun.DomainConfig("mg.example.com", region: .eu)
}
static var usDomain: Mailgun.DomainConfig {
return Mailgun.DomainConfig("mg2.example.com", region: .us)
}
}
mailgun.send(message, domain: .euDomain, on: req)
The new major version for this release is 3.0.0 to align with the supported Vapor version. 4.0.0 tag coming soon.
Fix for empty templates
In this release:
#34
Templates Support
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)
EU support
Merge pull request #31 from madsodgaard/feature/eu-support Add support for region selection
Added Inline Image Support
You can now add inline images that will display when the email is rendered. It uses the same format as image attachments.
Breaking API Changes
Merge pull request #20 from rafiki270/master readme update for the new code
Now supporting "reply-to" header
Merge pull request #17 from MihaelIsaev/patch-1 Implement replyTo