This came from a need to send emails with different providers -- Mailgun and Smtp2Go -- leveraging some shared low-level aspects. I know there are more mature libraries out there like FluentMail. As usual, I like building and thinking through stuff. I did actually get a little help from the FluentMail code base here for Mailgun.
I started with a base abstract class MailClientBase, then added implementations for
I offer these as NuGet packages:
All mail clients inherit from MailClientBase<TOptions>. Use TOptions
to define the settings required for that client. Examples: Mailgun Options, Smtp2Go Options.
For the two email providers in this repo I'm implementing, I overrode the abstract method SendImplementationAsync.
Html email rendering is a related but separate concern from this. I have a different project RazorToString that addresses this specifically.