我尝试通过c#发送邮件,但每次出现ssl错误。你能告诉我什么不对吗?
谢谢
SmtpClient mail = new SmtpClient();
MailMessage msg = new MailMessage("address", "address");
msg.Subject = "send data";
msg.Body = "Stuff";
mail.Credentials = new NetworkCredential("username", "pw");
mail.Host = "smtp.googlemail.com";
Attachment data = new Attachment(path1);
msg.Attachments.Add(data);
Attachment data2 = new Attachment(path2);
msg.Attachments.Add(data2);
Attachment data3 = new Attachment(path3);
msg.Attachments.Add(data3);
mail.Send(msg);
答案 0 :(得分:2)
mail.DeliveryMethod = SmtpDeliveryMethod.Network;
mail.EnableSsl = true;
mail.Port = 587;
答案 1 :(得分:1)
出现错误:服务器答案:5.3.2抱歉,在试用期内,您不能使用SMTP服务{mp018}
从这个错误我假设你刚刚注册了谷歌帐户,谷歌不允许你使用它的smtp服务,直到它的试用期结束。找出试用期有多长,并尝试何时结束
答案 2 :(得分:0)
尝试将mail.EnableSsl
设为true
。