Skip to content

Extends Transmitly to enable sending email communications with with any SMTP server

License

Notifications You must be signed in to change notification settings

transmitly/transmitly-channel-provider-smtp

Repository files navigation

Transmitly.ChannelProvider.Smtp

A Transmitly channel provider that enables sending Email communications through SMTP using MailKit

Getting started

To use the Smtp channel provider, first install the NuGet package:

dotnet add package Transmitly.ChannelProvider.Smtp

Then add the channel provider using AddSmtpSupport():

using Transmitly;
//...
var communicationClient = new CommunicationsClientBuilder()
.AddSmtpSupport(options =>
{
	options.Host = "smtp.test.com";
	options.Port = 587;
	options.UserName = "Test";
	options.Password = "Password";
})
//Pipelines are the heart of Transmitly. Pipelines allow you to define your communications
//as a domain action. This allows your domain code to stay agnostic to the details of how you
//may send out a transactional communication.
.AddPipeline("first-pipeline", pipeline =>
{
	//AddEmail is a Channel that is core to the Transmitly library. 
	//AsAudienceAddress() is also a convience method that helps us create an audience address
	//Audience addresses can be anything, email, phone, or even a device/app Id for push notifications!
	pipeline.AddEmail("from@mydomain.com".AsAudienceAddress("My From Display Name"), email =>
	{
		//Transmitly is a bit different. All of our communication content is configured by templates.
		//Out of the box, we have static or string templates, file and even embedded template support.
		//There are multiple types of templates to get you started. You can even create templates 
		//specific to certain cultures!
		email.Subject.AddStringTemplate("Check out Transmit.ly!");
		email.HtmlBody.AddStringTemplate("Hey, check out this cool communciations library. <a href=\"https://transmit.ly\">")
		email.TextBody.AddStringTemplate("Hey, check out this cool communciations library. https://transmitly.ly");
	});
})
.BuildClient();

//Dispatch (send) the transsactional email to our friend Joe (joe@mydomain.com) using our configured SMTP server and our "first-pipeline" pipeline.
var result = await communicationsClient.DispatchAsync("first-pipeline", "joe@mydomain.com".AsAudienceAddress("Joe"), new { });
  • Check out the Transmitly project for more details on what a channel provider is and how it can be used to improve how you manage your customer communications.
an open-source project sponsored by CiLabs of Code Impressions, LLC

Copyright © Code Impressions, LLC - Provided under the Apache License, Version 2.0.

About

Extends Transmitly to enable sending email communications with with any SMTP server

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages