Giter Site home page Giter Site logo

elarax.awsmailservice's Introduction

Service written in .NETCore for sending emails from AWS Email Credentials.

Install Package

dotnet add package Elarax.AwsMailService

Configure Startup

Obtain SMTP Credentials from AWS

https://docs.aws.amazon.com/ses/latest/dg/smtp-credentials.html

Update appSettings.json

"AwsKeys": {
	"ApiKey": "AWS_API_KEY",
	"ApiSecret": "AWS_API_SECRET_KEY",
	"Server": "EMAIL SERVER"
},

Add to pipeline

builder.Services.AddEmailService(options =>
{
	options.ApiKey = builder.Configuration["AwsKeys:ApiKey"];
	options.ApiSecret = builder.Configuration["AwsKeys:ApiKey"];
	//options.From = Configuration["AwsKeys:From"]; // optional
	options.Server = builder.Configuration["AwsKeys:Server"];
});

Send Email

using Elarax.AwsMailService;

private readonly IEmailService emailService;

public ConfigurationsController(IEmailService emailService)
{
	this.emailService = emailService;
}

public async Task<JsonResult> SendTestEmail(string sendermail)
{
	var toEmail = "[email protected]";

	var mail = new System.Net.Mail.MailMessage();
	mail.To.Add(toEmail);

	mail.Subject = "Test Email";
	mail.Body = "<html><body style='font-family:Arial'<p>Hello from Elarax.AwsMailService</p>" +
							"<p>This is a test mail</p>" +
							"<br />"+
							"<p>*please ignore this mail</p></body></html>";

	bool isEmailSuccess = await emailService.SendEmailAsync(mail);
	return Json(new { Result = isEmailSuccess ? "success" : "failure" });
}

elarax.awsmailservice's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.