- Download the package on NuGet
- Create a
Providerinstance (see Providers) - Use the Fluent API to configure Mailocomotive
Api.Configuration()
.UseProjectRoot(path)//optional
.UseProvider(provider);- Create an email by creating a class that implements
Mailocomotive.Email<TViewModel>:
internal class ExampleMail:Email<string>
{
public ExampleMail()
{
ViewPath = "/Email.cshtml";
}
public override string BuildViewModel()
{
return "setarit";
}
}- Configure the email headers and send the mail
await email
.From("Sender", "sender@example.com")
.To("Demo", "demo@example.com")
.Subject("Demo")
.SendAsync();Currently the package only supports SMTP providers.
If you use only one SMTP provider use SmtpMailProvder
It's possible that you have multiple providers.
You can choose to rotate between the available providers, or let the package pick one at random.
Use the SmtpMailProviderCollection.
The Collection property contains all the SmtpMailProvders to use.
The Strategy property contains the how the package should handle the collection.
| Strategy | Description |
|---|---|
ROTATE |
Tries to send the mail with the first provider. If that fail it tries the second, if the second fails then it tries the third and so on. Throws the last exception if all failed with exception |
RANDOM |
Uses a random provider from the collection to send. If the provider fails, another provider will be selected at random. When all the providers in the collection fail, it will throw the exception from the last provider |
You can find examples in the Examples folder