I set all params, but I get exception: An exception of type 'System.Net.Mail.SmtpException' occurred in System.dll but was not handled in user code
Please, help with this issue.
var verifyUrl = "/User/VerifyAccount" + activateCode;
var link = Request.Url.AbsoluteUri.Replace(Request.Url.PathAndQuery, verifyUrl);
var fromEmail = new MailAddress("******@gmail.com", "Dotnet Awesome");
var toEmail = new MailAddress(email);
var fromEmailPassword = "******";
string subject = "Your account is successfully created!";
string body = "<br/><br/>We are excitef to tell you Dotnet Awesome is" +
"successfully created. Please click on the link to verify your account" +
"<a href'" + link + "'>" + link + "</a>";
var smtp = new SmtpClient
{
Host = "smpt.gmail.com",
Port = 587,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
Credentials = new NetworkCredential(fromEmail.Address, fromEmailPassword)
};
using (var message = new MailMessage(fromEmail, toEmail)
{
Subject = subject,
Body = body,
IsBodyHtml = true
})
{
smtp.Send(message);//Exception here
}
我认为您可以检查一个Host =“ smpt.gmail.com”,因为您使用的是smpt而不是smtp
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.