【发布时间】:2014-10-30 13:46:48
【问题描述】:
这个问题已经被问过了,我已经尝试了我在堆栈溢出中发现的每一件事>
using (MailMessage mm = new MailMessage("sender@gmail.com", txtEmail.Text))
{
mm.Subject = "Account Activation";
string body = "Hello " + txtUsername.Text.Trim() + ",";
body += "<br /><br />Please click the following link to activate your account";
body += "<br /><a href = '" + Request.Url.AbsoluteUri.Replace("CS.aspx", "CS_Activation.aspx?ActivationCode=" + activationCode) + "'>Click here to activate your account.</a>";
body += "<br /><br />Thanks";
mm.Body = body;
mm.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.EnableSsl = true;
smtp.UseDefaultCredentials = false;
NetworkCredential NetworkCred = new NetworkCredential("sender@gmail.com", "password");
smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtp.Credentials = NetworkCred;
smtp.Send(mm);
}
我尝试将默认凭据更改为 false,我注意到当我更改端口号时。从 587 到 465 我连接超时。
【问题讨论】:
标签: c# email email-validation