Skip to content

JGMelon22/AutomaticMailSenderPOC

Repository files navigation

AutomaticMailSenderPOC

This is a simple ASP .NET Core Web API to send E-mails using MailKit and Mailtrap free service.
The motivation for this project is to send e-emails in batches to have success contact with my college course coordinator, as he never responds.

Tech Stack

dotnet  swagger  zedindustries 

How to build and execute it? 🛠️

First of all, make sure you have .NET 8 SDK installed and a Mailtrap account
  • Clone the repository
  • Inside of the sln directory, restore the dependencies with dotnet restore
  • Change the directory to AutomaticMailSenderPOC with cd AutomaticMailSenderPOC and execute the project with dotnet run
  • After that, you either have to init and create an user-secret or manually populate the appsettings.json file to bind some data.

First approach: populating appsettings.json

  1. Include the following code in the configuration file:
  2. "SmtpSettings": {
       "Server": "sandbox.smtp.mailtrap.io",
       "Port": 2525,
       "SenderEmail": "[email protected]",
       "Username": "Your Username",
       "Password": "Your safe password",
       "MailTrapUserName": "Your Mailtrap Username",
       "MailTrapPassword": "Your Mailtrap Password"
    }

Second approach: using dotnet user secrets

  1. Inside the csproj directory, initialize the user secrets with: dotnet user-secrets init
  2. Then, one by one, type the following in the terminal:
  3. dotnet user-secrets set "SmtpSettings:Server" "sandbox.smtp.mailtrap.io"
    dotnet user-secrets set "SmtpSettings:Port" "2525"
    dotnet user-secrets set "SmtpSettings:SenderEmail" "[email protected]"
    dotnet user-secrets set "SmtpSettings:Username" "Your Username"
    dotnet user-secrets set "SmtpSettings:Password" "Your safe password"
    dotnet user-secrets set "SmtpSettings:MailTrapUserName" "Your MailTrap Username"
    dotnet user-secrets set "SmtpSettings:MailTrapPassword" "Your MailTrap Password"
    
zed-editor swagger-ui

References 📚

ASP.NET Core - Enviando emails com Mailkit em uma API
MailKit Documentation
MailKit GitHub Project

About

Send e-mails in batches using MailKit with ASP .NET Core

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages