我最近收到错误:ystem.Net.Mail.SmtpException:发送邮件失败。---> System.Net.WebException:无法连接到远程服务器 ---> System.Net.Sockets.SocketException。而且我以前从来没有这样做过,就在两周前,我的 C# 服务器端代码运行良好:
MailMessage myEmail = new MailMessage()
{
Subject = "Message from website user:" + Name + "",
Body = "Email Address: " + email + Environment.NewLine + Environment.NewLine + "Message:" + Environment.NewLine + message,
IsBodyHtml = false,
From = new MailAddress(email, Name)
};
myEmail.To.Add(new MailAddress("yakov_mora@gmail.com"));
SmtpClient server = new SmtpClient();
server.Port = 25;
server.Send(myEmail);
我的网络配置:
system.net>
<mailSettings>
<smtp deliveryMethod="Network">
<network port="587" host="smtp.gmail.com" enableSsl="true" defaultCredentials="false" userName="yakov_mora@walla.com" password="0545674811" />
</smtp>
</mailSettings>
请帮忙!