This can be done easily by using Smtp4dev utility without having any smtp server setup.
Download the smtp dev utility from below url. That has a single executable file and no need of any installation for this. Once you start running the exe file, you will be able to see the application open.
You can minimize that application that will be added into system tray and will be listening for any email that comes to localhost.

Don’t worry, you do not need to setup anything for smtp localhost. All you need to do is, run the Smtp4Dev exe and send email using SmtpClient by pointing to the server address as “127.0.0.1” or “localhost”.
You can From address and To address as any valid email address. Also, subject and messages are free text.
Once you send the email using SmtpClient, you will see the email notification from the System tray. Click on that popup to view the email in the Smtp4dev client. That’s all.


Below code will give you better idea.
class Program
{
static void Main(string[] args)
{
SMTPDevEmailDemo smtpDevEmailDemo = new SMTPDevEmailDemo();
smtpDevEmailDemo.SendEmail(new EmailRequst() { From = "smtpdevfrom@smtpdev.com", To = "smtpdevto@smtpdev.com", Subject = "Test email", Message = "Hello to local email" });
}
}
namespace DemoCodes
{
public class SMTPDevEmailDemo
{
public void SendEmail(EmailRequst emailRequest)
{
SmtpClient smtpClient = new SmtpClient("127.0.0.1");
smtpClient.Send(
emailRequest.From,
emailRequest.To,
emailRequest.Subject,
emailRequest.Message);
}
}
public class EmailRequst
{
public string From { get; set; }
public string To { get; set; }
public string Subject { get; set; }
public string Message { get; set; }
}
}