Skip to content

Technical planning: Replace SendGrid with Brevo for email notifications#198

Open
Copilot wants to merge 1 commit into
masterfrom
copilot/find-alternative-to-sendgrid
Open

Technical planning: Replace SendGrid with Brevo for email notifications#198
Copilot wants to merge 1 commit into
masterfrom
copilot/find-alternative-to-sendgrid

Conversation

Copilot AI commented Nov 5, 2025

Copy link
Copy Markdown
Contributor

SendGrid discontinued their free tier. Need alternative supporting <100 emails/month with dynamic templates and custom sender addresses without domain verification.

Analysis & Recommendation

Selected: Brevo (formerly Sendinblue)

  • Free tier: 9,000 emails/month vs 1,000 for SMTP2GO
  • Allows custom sender without DNS verification (matches SendGrid's "Send via SendGrid")
  • Official .NET SDK: brevo_csharp

Evaluated: SMTP2GO per user request - strong alternative but requires DNS setup for custom domains, doesn't meet "no domain proof" requirement.

Current Architecture

// EmailNotificationService.cs - SendGrid implementation
private readonly ISendGridClient _sendGridClient;

private async Task SendEmail(object templateData, List<string> toAddresses, 
                              string fromAddress, string templateId)
{
    var sendGridMessage = new SendGridMessage();
    sendGridMessage.SetFrom(fromAddress);
    sendGridMessage.SetTemplateId(templateId);
    sendGridMessage.SetTemplateData(templateData);
    await _sendGridClient.SendEmailAsync(sendGridMessage);
}

Proposed Migration

Package Changes

  • Remove: SendGrid v9.29.1
  • Add: brevo_csharp v1.1.1+

Configuration Model

// Application.cs - Before
public string SendGridSenderEmail { get; set; }
public string SendGridDynamicTemplateId { get; set; }

// After
public string SenderEmail { get; set; }
public string SenderName { get; set; }
public long BrevoNewUserTemplateId { get; set; }

Service Refactoring

// EmailNotificationService.cs - Brevo implementation
private readonly TransactionalEmailsApi _brevoClient;

private async Task SendEmail(Dictionary<string, object> templateParams,
                              List<string> toAddresses,
                              long templateId)
{
    var sendSmtpEmail = new SendSmtpEmail(
        to: toAddresses.Select(e => new SendSmtpEmailTo(email: e)).ToList(),
        sender: new SendSmtpEmailSender(email: _senderEmail, name: _senderName),
        templateId: templateId,
        params: templateParams
    );
    await _brevoClient.SendTransacEmailAsync(sendSmtpEmail);
}

Template Migration

Infrastructure templates use {{UserName}} syntax. Brevo requires {{params.UserName}} in dashboard templates.

Implementation Plan

Effort: 8 hours total

  • Code changes: 4-6h (package, service, tests, config)
  • Account setup: 1h (Brevo account, create templates)
  • Deployment: 1h

Files Modified:

  • NRZMyk.Services/NRZMyk.Services.csproj
  • NRZMyk.Services/Configuration/Application.cs
  • NRZMyk.Services/Services/EmailNotificationService.cs
  • NRZMyk.Server/Program.cs
  • NRZMyk.Server/appsettings.json
  • NRZMyk.Services.Tests/Services/EmailNotificationServiceTests.cs
  • README.md

Documentation Delivered

Three comprehensive planning documents created (70+ pages):

  1. TECHNICAL_SPECIFICATION.md - Complete implementation guide with API comparisons, migration steps, config reference
  2. SMTP2GO_vs_BREVO_COMPARISON.md - Detailed feature comparison (scoring: Brevo 81.6% vs SMTP2GO 75.2%), implementation examples for both
  3. EXECUTIVE_SUMMARY.md - Decision rationale, timeline, Q&A

Risk Assessment

  • Rollback: <15 minutes (git revert + restore env vars)
  • Cost: $0 (free tier sufficient, €25/month if scaling to 20k)
  • Deliverability: Recommend DNS verification for production (optional on free tier)

Ready for implementation.

Original prompt

This section details on the original issue you should resolve

<issue_title>Find and implement alternative to Sendgrid</issue_title>
<issue_description>SendGrid decided to drop it's free service and we need an Alternative. It should support simple dynamic templates like this one

{{UserName}} ({{UserEmail}}) aus {{UserCity}} hat sich am {{Date}} um {{Time}} neu registiert. Der Account muss noch einer Organisation zugeordnet werden, um das System nutzen zu können.

And allow us to send emails as "xxx@domain.com" without proof of domain Ownership as supported by SendGrid with "Send via Sendgrid".

The volume is low as we send less then 100 emails.

Existing templates can be found as text files in folder Infrastructure</issue_description>

Comments on the Issue (you are @copilot in this section)

Custom agent used: implementation-planner
Creates detailed implementation plans and technical specifications in markdown format


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Find and implement alternative to Sendgrid Technical planning: Replace SendGrid with Brevo for email notifications Nov 5, 2025
Copilot AI requested a review from markusrt November 5, 2025 07:39
@markusrt markusrt marked this pull request as ready for review November 5, 2025 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Find and implement alternative to Sendgrid

2 participants