以下是单击按钮触发的asp代码。我在Windows 7家庭premiun工作。我收到错误'操作已超时'也尝试了端口587但得到错误'SMTP服务器需要安全连接或客户端未经过身份验证。 “
public void SendEmailFromCommAgent(string subject, string body, string to)
{
try
{
SmtpClient mc = new SmtpClient("smtp.gmail.com",465);
MailMessage msg = new MailMessage("xxxxxxx@gmail.com", to, subject, body);
mc.EnableSsl = true;
mc.UseDefaultCredentials = false;
mc.Credentials = new System.Net.NetworkCredential("xxxxxxxxxxxx@gmail.com", "xxxxxxxxxxxxxxx");
msg.From = new MailAddress("xxxxxxxxxxx@gmail.com");
mc.DeliveryMethod = SmtpDeliveryMethod.Network;
mc.Timeout = 50000;
msg.IsBodyHtml = true;
mc.Send(msg);
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
}
IIS配置 电子邮件地址:xxx@gmail.com smtp服务器:smtp.gmail.com 港口:465 指定凭据:用户名xxxxx@gmail.com密码xxxxxxx
任何帮助都会很棒:)