Transmitly.ChannelProvider.Mailgun is the convenience package for sending email with Transmitly through Mailgun.
This is the package most applications should install. It wires together:
Transmitly.ChannelProvider.Mailgun.ConfigurationTransmitly.ChannelProvider.Mailgun.Api
Supported channels:
Email
dotnet add package Transmitly.ChannelProvider.Mailgunusing Transmitly;
ICommunicationsClient client = new CommunicationsClientBuilder()
.AddMailgunSupport(options =>
{
options.ApiKey = "key-your-mailgun-api-key";
options.SendingDomain = "mg.example.com";
})
.AddPipeline("welcome-email", pipeline =>
{
pipeline.AddEmail("welcome@example.com".AsIdentityAddress("Example App"), email =>
{
email.Subject.AddStringTemplate("Welcome to Example App");
email.HtmlBody.AddStringTemplate("<strong>Welcome</strong> to Example App.");
email.TextBody.AddStringTemplate("Welcome to Example App.");
});
})
.BuildClient();
var result = await client.DispatchAsync(
"welcome-email",
"customer@example.com",
new { });AddMailgunSupport(options => ...) accepts MailgunOptions.
Common settings:
ApiKey: your Mailgun API key.SendingDomain: the Mailgun sending domain, such asmg.example.com.ApiHost: defaults tohttps://api.mailgun.net.ApiVersion: defaults tov3.WebProxy: optional outbound proxy.
This package registers Mailgun email extensions through email.Mailgun().
Common provider-specific settings include:
- stored Mailgun templates via
TemplateandTemplateVersion - AMP email via
AmpHtml - tags and custom properties
- DKIM and TLS options
- Mailgun tracking flags
Example:
using System.Collections.Generic;
using Transmitly;
pipeline.AddEmail("welcome@example.com".AsIdentityAddress("Example App"), email =>
{
email.Subject.AddStringTemplate("Welcome to Example App");
email.TextBody.AddStringTemplate("Welcome to Example App.");
email.Mailgun().Tags = new[] { "welcome", "transactional" };
email.Mailgun().Tracking = true;
email.Mailgun().Properties = new Dictionary<string, string>
{
["v:tenant"] = "default"
};
});This package registers a Mailgun delivery-report adaptor, so Mailgun webhook payloads can be converted into Transmitly DeliveryReport instances.
It also registers Mailgun delivery-report extended properties, which makes report.Mailgun() available when you need provider-specific webhook data.
Copyright (c) Code Impressions, LLC. This open-source project is sponsored and maintained by Code Impressions and is licensed under the Apache License, Version 2.0.