Home

Awesome

Warden SendGrid Integration

Warden

OPEN SOURCE & CROSS-PLATFORM TOOL FOR SIMPLIFIED MONITORING

getwarden.net

BranchBuild status
mastermaster branch build status
developdevelop branch build status

SendGridIntegration can be used for sending the emails via SendGrid. Both, standard email messages and transactional templates are supported. You may use either API key or credentials (username and password) to connect to your SendGrid account.

Installation:

Available as a NuGet package.

dotnet add package Warden.Integrations.SendGrid

Configuration:

SendGridIntegration can be configured by using the SendGridIntegrationConfiguration class or via the lambda expression passed to a specialized constructor.

Initialization:

In order to register and resolve SendGridIntegration make use of the available extension methods while configuring the Warden:

var wardenConfiguration = WardenConfiguration
    .Create()
    .IntegrateWithSendGrid("api-key", "noreply@system.com", cfg =>
    {
        cfg.WithDefaultSubject("Monitoring status")
           .WithDefaultReceivers("admin@system.com");
    })
    .SetGlobalWatcherHooks((hooks, integrations) =>
    {
        hooks.OnStart(check => GlobalHookOnStart(check))
             .OnFailure(result => integrations.SendGrid().SendEmailAsync("Monitoring errors have occured."))
    })
    //Configure watchers, hooks etc..

You may either use the API key or credentials (username and password). The last required parameter is the default sender email address e.g. noreply@system.com.

Custom interfaces:

public interface IEmailSender
{
    Task SendMessageAsync(string username, string password, SendGridMessage message);
    Task SendMessageAsync(string apiKey, SendGridMessage message);
}

IEmailSender is responsible for sending the email messages. It can be configured via the WithEmailSenderProvider() method. By default, it is based on the SendGrid Web instance.