Freelance Project Requests Software Development in C# WPF Asp.Net Core Vba Excel Word SQL-Server EF Linq, UWP Net



By default, Asp Net Core MVC refers to the Api interface to the Email Service Provider: EmailGrid.

But you can also just set up your own email client to an email server like MailEnable.

Mailenable is a free email system and runs stably on all windows servers.



Set Email Sender


The program that processes the emails that are sent will be written to the Services / EmailSender.cs file.

Initially, the SendEmailAsync method is empty as a task.


Email Sender Default Code:

This code must be changed to Asp.Net Core MVC

// This class is used by the application to send email for account confirmation and password reset.

// For more details see

public class EmailSender : IEmailSender


     public Task SendEmailAsync(string email, string subject, string message)


         return Task.CompletedTask;




EmailSender: New code

Email code for MailEnable server under Asp.Net Core 2 MVC

The code can be set to Pop, SMTP SSL.

Here is the code for a simple pop client

using System;

using System.Collections.Generic;

using System.Linq;

using System.Net;       //NetworkCredential

using System.Net.Mail;  //SmtpClient

using System.Threading.Tasks;


namespace Readdy.Services


    // This class is used by the application to send email for account confirmation and password reset.

    public class EmailSender : IEmailSender


        public async Task SendEmailAsync(string To_Email_Address, string subject, string message)


            //------------< SendEmailAsync() >------------

            //< check >

            if (To_Email_Address == null) return//todo <bool>=false

            //</ check >




                //< init >

                string sFrom_Email_Address = "";

                string sFrom_Email_DisplayName =  "Mailservice";

                string sSenderAppname = "Readdy.Net";

                string sHost = "";

                int intPort = 25;

                string sEmail_Login = "";

                string sEmail_Passwort = "your_passwort_for_smtp_server";

                //</ init >


                //-< setup Email >-

                MailMessage email = new MailMessage();

                email.To.Add(new MailAddress(To_Email_Address));

                email.From=new MailAddress(sFrom_Email_Address,sFrom_Email_DisplayName);

                email.Subject = sSenderAppname + " " + subject;

                email.Body = message;

                email.IsBodyHtml = true;

                //email.Priority = MailPriority.High;

                //-</ setup Email >-


                //-< EmailClient >-

                SmtpClient smtp = new SmtpClient();

                smtp.Host = sHost;

                smtp.Port = intPort;

                smtp.Credentials = new NetworkCredential(sEmail_Login, sEmail_Passwort);

                smtp.EnableSsl = false;

                //-</ EmailClient >-


                //< send >

                await smtp.SendMailAsync(email);

                //</ send >



            catch (Exception ex)


                //do something here

                Console.WriteLine("Error EmailSender.cs error:" + ex.InnerException);




            //return true;

            //------------</ SendEmailAsync() >------------






More settings


Task: Change ForgotPassword

If you want to test the email server, then you can do this via the email confirmation.

[Lnk "https://Readdy.Net/Account/ForgotPassword" /]


Change Task: ForgotPassword

The method ForgotPasswort checks whether the user exists and whether the email has already been confirmed.

In my opinion, the query: User.IsEmailConfirmded will turn off.

Code in Controller / AccountController / ForgotPassword

Mark the yellow line

public async Task<IActionResult> ForgotPassword(ForgotPasswordViewModel model)


            if (ModelState.IsValid)


                var user = await _userManager.FindByEmailAsync(model.Email);

                if (user == null//|| !(await _userManager.IsEmailConfirmedAsync(user))


                    // Don't reveal that the user does not exist or is not confirmed

                    return RedirectToAction(nameof(ForgotPasswordConfirmation));






The EmailConfirmed query refers to the Asp.MVC table: dbo.AspNetUsers and the column: EmailConfirmed



More errors

When setting up the email connection, further error messages may come from the server:


Error Message Mail Server:

User not local; please try a different path. The server response was: Sender address is not valid for your login. Check your email program settings.



Email_From Address must exist


Error Message Mail Server:

Syntax error, command unrecognized. The server response was: Welcome to MailEnable POP3 Server


Port Address is 25 not 110 on MailEnable Pop





Further information:


Email Sender Interface

Below EmailsSender.cs is the file IEmailSender.cs.

This includes the so-called interface. The interface is used as a kind of template to which all email applications are tailored.

When using the Asp Net MVC Core with Email clients via Net.Sy


Email Interface

public interface IEmailSender


 Task SendEmailAsync(string email, string subject, string message);




Browser in Asp.Net Core 2 with Wangkanai
Asp.Net Core 2 MVC: Email Sender Client Write.
Asp core: Cookie read and write
Asp MVC Core: Display HTML text as HTML elements
Asp: HTML to Text convert
Asp.Net code example


Contact for Jobs, Project Requests: