Skip to content

dannykentala/MailerSendService

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Configuration

appsettings.json

"EmailServiceOptions": {
  "ApiEmail": "<email_name>@<domain_name>",
  "ApiToken": "<your_domain_token>",
  "ApiUrl": "https://api.mailersend.com/v1/email"
}

Program.cs

//----- Libraries injection
builder.Services.AddScoped<MailerSendService>();

Controller

using MailerSendApi;
using MailerSendApi.Models;
using Microsoft.AspNetCore.Mvc;

namespace SchoolApi.Controllers
{
  [Route("api/emails")]
  [ApiController]
  public class MailerSendController: ControllerBase
  {
    // Dependency injection of mailerSendService
    private readonly MailerSendService _mailerSendService;
    public MailerSendController(MailerSendService mailerSendService)
    {
      _mailerSendService = mailerSendService;
    }

    [HttpGet]
    public async Task<string> GetAll()
    {
      Email newEmail = new Email
      {
        To = 
        [
          new Recipent{Email = "<recipent_email>"}
        ],
        Subject = "Email from backend",
        Html = "This is an email generate from backend, but with Library"
      };

      string emailInfo = await _mailerSendService.SendEmail(newEmail);
      return emailInfo;
    }
  }
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published