This ASP.NET Core MVC web application allows users to register with their name, email, and password. After registration, user data is saved to a SQL database, and a congratulatory email is sent to the provided email address.
- User registration form (Name, Email, Password)
- Data stored using Entity Framework Core (EF Core)
- Sends a welcome email using Gmail SMTP
- .NET SDK 6.0 or later
- Visual Studio 2022 / Visual Studio Code
- SQL Server or SQLite
- Gmail account with App Password
Install via terminal or NuGet Package Manager:
dotnet add package Microsoft.EntityFrameworkCore
dotnet add package Microsoft.EntityFrameworkCore.SqlServer
dotnet add package Microsoft.EntityFrameworkCore.Tools-
Clone the repository
git clone https://github.com/aa-maruf/EmailSender.MVC.git cd EmailSender.MVC -
Configure Gmail App Password
Google blocks direct SMTP logins with your normal password. To send emails using Gmail SMTP:
-
Enable 2-Step Verification in your Google Account: 👉 myaccount.google.com/security
-
Go to App Passwords, select Mail, and name it (e.g.,
ASP.NET App). -
Google will generate a 16-digit app password (e.g.,
abcd efgh ijkl mnop). -
Set it as an environment variable in your system:
setx gmail_pass "your-app-password"
-
-
Update
EmailSender.csReplace the placeholder email with your Gmail:
var username = "your_email@gmail.com"; var fromEmail = "your_email@gmail.com";
-
Run EF Core Migrations
In the Package Manager Console:
Add-Migration InitialCreate Update-Database
-
Run the application
dotnet run
Controllers/UserController.cs– Handles form submission and email sendingModels/User.cs– User model for EF CoreData/EmployeeDBContext.cs– EF Core database contextService/EmailSender.cs– Sends congratulatory emailsViews/User/Create.cshtml– Registration form UIViews/User/Index.cshtml– Displays list of registered users
<h2>Congratulations, Alice!</h2>
<p>Your account has been created successfully.</p>