Giter Club home page Giter Club logo

background-email-sender's Introduction

Background email sender sample

This is a contact form ASP.NET Core 3.1 application. E-mail messages are not sent right away, but they are pushed to a queue managed by an ASP.NET Core Hosted Service. This means the client won't have to wait for the actual delivery. Each message is then dequeued and delivered in background. In case of an error during delivery, a message is re-queued for later processing.

Check out the actual Hosted Service implementation in the code file HostedServices/EmailSenderHostedService.cs.

The Hosted Service has to be registered int the ConfigureServices method of the Startup class. Take a look at the Startup.cs file.

Dependencies

This project uses the MailKit package to deliver emails. The Hosted Service implements the IEmailSender interface from the Microsoft.AspNetCore.Identity.UI but you can make it implement some other similar interface if you don't want to depend upon ASP.NET Core Identity.

Warning

This code is NOT production-ready. It just illustrates how to implement and register a Hosted Service for sending e-mails in background. Some messages might be lost when the application is restarted since it does not implement a persistent storage (e.g. a database).

See this fork by AngeloDotNet for a more complete implementation using persistent storage (Sqlite). https://github.com/AngeloDotNet/BackgroundEmailSender

Moreover, this project it does not deliver email messages in parallel or throttle them to prevent reaching a quota.

Getting started

Edit the appsettings.json file with your SMTP server data. Then, just run the application by typing dotnet run. The .NET Core SDK 3.1 (or greater) must be installed in your system. Fill in the form and hit the Send button. home.png

background-email-sender's People

Contributors

brightsoul avatar azzeccagarbugli avatar

Watchers

James Cloos 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.