@IT_DrKaako , I am not sure how to do that without purchasing a service. I suppose you could set-up your own mail server. But I took the easy route and purchased an email account from GoDaddy for my domain. I purchased the domain from GoDaddy as well.
The email address I purchased was ******@mydomain.com. I can send emails from that account by logging into the account from Microsoft Outlook, or I can also send emails from my ASP.Net MVC app using Twillo Sendgrid. See below for an example.
using SendGrid;
using SendGrid.Helpers.Mail;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace MyShoppingCart.Helpers
{
public static class SendGridStatic
{
public static async Task Execute(string sSendGridKey, string sFromEmail, string sFromName, string sSubject, string sToEmail, string sToName, string sPlainTextContent = "", string sHTMLContent = "")
{
var apiKey = sSendGridKey;
var client = new SendGridClient(apiKey);
var from = new EmailAddress(sFromEmail, sFromName);
var subject = sSubject;
var to = new EmailAddress(sToEmail, sToName);
var plainTextContent = sPlainTextContent;
var htmlContent = sHTMLContent;
var msg = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, htmlContent);
var response = await client.SendEmailAsync(msg);
}
}
}
An example of calling that method:
private async Task SendConfirmationEmail(ApplicationUser user)
{
string sEmailToken = await _userManager.GenerateEmailConfirmationTokenAsync(user);
string sURL = $"{_configuration.GetValue<string>("SiteURL")}Account/Verify?Id={Uri.EscapeDataString(user.Id)}&token={Uri.EscapeDataString(sEmailToken)}";
string sPlainTextContent = $"Please click the following link to verify your email: {sURL}";
string sHTMLContent = $"<strong>Please click the following link to verify your email:</strong><br>{sURL}";
await SendGridStatic.Execute(_configuration.GetValue<string>("SendGridKey"), "******@mydomain.com", "Customer Service", "Please Verify Your Account", user.Email, user.FullName, sPlainTextContent, sHTMLContent);
}
I had to get a FREE Sendgrid account, and do some set-up in order to have access to the SendGrid API in order to get this to work, but it wasn't too difficult.
Does that answer your question?