Hello all can anyone please explain what would the UserName and Password be? I believe that those are asking for my gmail's username and password right? (I'm the one who will always receive emails) I am trying to implement the email service for my contact form. Sorry I'm pretty new to asp.net mvc.
public class MailService : IMailService
{
public string SendMail(string from, string to, string subject, string body)
{
var errorMessage = "";
try
{
var msg = new MailMessage(from, to, subject, body);
using (var smtp = new SmtpClient())
{
var credential = new NetworkCredential
{
UserName = "[email protected]",
Password = "password"
};
smtp.Credentials = credential;
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.EnableSsl = true;
smtp.Send(msg);
}
}
catch (Exception ex)
{
errorMessage = ex.Message;
}
return errorMessage;
}
}