返回首页

下面的错误是发生在我的code.I希望通过SMTP服务发送邮件通过Gmail。 :

SMTP服务器要求安全连接或客户端未通过身份验证。服务器响应为:5.7.0必须先发出STARTTLS命令。 g14sm3507891wfh.10。
代码编写:

emailid = table.Rows[0]["EmailId"].ToString();

					MailMessage mail = new MailMessage();

					mail.To.Add(emailid);

					mail.From = new MailAddress(txtemail.Text.ToString());

					mail.Subject = "Registration";

					string Body = "Please Approve my Registration";

					mail.Body = Body;

					SmtpClient smtp = new SmtpClient("127.0.0.1");

					smtp.Host = "smtp.gmail.com";

					try

					{

						smtp.Send(mail);

						Response.Write("Mail sent successfully");

						clearcontrol();

					}

					catch (Exception ex)

					{

						Response.Write("Mail send failed");

					}
| Ujwala Gholap:digimanus:Gmail不使用SMTP端口25。见fopr代码]

回答