【问题标题】:ASP.NET - Error sending email MessagesASP.NET - 发送电子邮件消息时出错
【发布时间】:2016-03-30 10:28:54
【问题描述】:

我检查了其他问题,并且能够解决我的代码中的一些错误,但是 smtp.Credentials = nc; (其中 nc 是我的网络凭据)抛出异常,请求操作在 MFE 代理上中止,SMTP 服务器是不可用。

请,任何帮助将不胜感激。下面是我的代码:

           MailMessage msg = new MailMessage();
            msg.From = new MailAddress("fromemail");
            msg.To.Add("toemail");
            msg.Subject = "Contact Us";
            msg.Body = cname.Text + "sent me this message" + cmessage.Text + "with this email, " + email.Text;
            msg.IsBodyHtml = true;

            SmtpClient smtp = new SmtpClient();
            smtp.Host = "smtp.gmail.com";
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
            smtp.EnableSsl = false;
            smtp.UseDefaultCredentials = false;
            smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
            NetworkCredential nc = new NetworkCredential();
            nc.UserName = "fromemail";
            nc.Password = "fromemailpwd";
            smtp.Credentials = nc;
            smtp.Port = 587;
            smtp.Send(msg);
            sPanel.Visible = true;
            lblSuccess.Text = "Success! Thanks for contacting us, we will get back to you soon.";

我将smtp.Credentials = nc 更改为smtp.Credentials = new NetworkCredentials("fromemail", "fromemailpwd"); 现在,正是这行 smtp.Send(msg) 引发了异常。

【问题讨论】:

    标签: c# asp.net smtp gmail system.net.mail


    【解决方案1】:

    我无法收到与您看到的相同的错误消息,但请查看此答案:Request action aborted on MFE proxy, SMTP server is not available

    不过,我知道 Gmail 需要 EnableSSL = True

    【讨论】:

    • 谢谢,我更改了邮箱地址,检查链接后,现在它说操作已超时,即使我增加了 smtp.timeout。
    猜你喜欢
    • 1970-01-01
    • 2012-10-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-14
    相关资源
    最近更新 更多