这是我的代码:
System.Net.NetworkCredential cred = new System.Net.NetworkCredential("example@gmail.com", "example12345");
System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
msg.To.Add("friend@gmail.com");
msg.From = new System.Net.Mail.MailAddress("example@gmail.com", "blah");
msg.Subject = "Subject";
msg.Body = "Hello";
System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient("smtp.gmail.com", 25);
client.Credentials = cred;
client.EnableSsl = true;
client.Send(msg);
错误是:
客户端无权向此服务器提交邮件。服务器响应为:5.5.1 STARTTLS可能不会重复。
在System.Net.Mail.SmtpConnection.GetConnection(String host,Int32 port)的System.Net.Mail.StartTlsCommand.Send(SmtpConnection conn)上的<。System.Net.Mail.StartTlsCommand.CheckResponse(SmtpStatusCode statusCode,String response)在System.Net.Mail.SmtpTransport.GetConnection(字符串主机,Int32端口)的System.Net.Mail.SmtpClient.GetConnection()处于System.Net.Mail.SmtpClient.Send(MailMessage消息)