A .NET example for sending emails using MailKit and MimeKit. This project demonstrates how to:
- Send basic email messages
- Attach files
- Send HTML content
Here are some of the project's best features:
- Easy-to-follow examples
- Asynchronous email sending
-
Clone the Repository
git clone https://github.com/ziadhanii/sending-emails-with-mailkit-and-mimekit.git
-
Install Dependencies
dotnet restore
-
Configure Email Settings
Update the
appsettings.json
file with your email server details:{ "Logging": { "LogLevel": { "Default": "Information", "Microsoft.AspNetCore": "Warning" } }, "AllowedHosts": "*", "EmailSettings": { "Host": "smtp.gmail.com", "Port": 587, "SenderName": "Your Name", "Email": "your-email", // **Ensure to enter your email here** "Password": "your-email-password" // **Ensure to enter your password here** } }
Here is a screenshot of the project: