试图以其访问权限禁止的方式访问套接字173.194.175.108:587

时间:2019-06-13 16:33:37

标签: asp.net

在ASP.net表单上单击“提交”按钮时,出现此Web套接字错误

根据我的虚拟主机,这不是防火墙阻止该功能

private void sendMail()
    {
        var fromAddress = new MailAddress("xxx@gmail.com");
        var fromPassword = "XXXX";
        var toAddress = new MailAddress("yyy@gmail.com");

        System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient
        {
            Host = "relay-hosting.secureserver.net",
            Port = 25,
            EnableSsl = true,
            DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network,
            UseDefaultCredentials = false,
            Credentials = new System.Net.NetworkCredential(fromAddress.Address, fromPassword)
        };

        using (var message = new MailMessage(fromAddress, toAddress)
        {
            Subject = "New Reservation: " + DateTime.Now,
            Body = "Name: " + name.Text + "\n"+ "Date: " + date.Text + "\n" + "Time: " + time.Text + "\n" + "Number of people: " + numberOfPeople.Text + "\n" + "Phone number: " + phoneNumber.Text + "\n" + "Email Address: " + emailAddress.Text + "\n" + "Karaoke: " + karaoke.Text + "\n" + "Catering: " + catering.Text + "\n" + "Additional info: " + additionalInfo.Text
        }
            )
            smtp.Send(message);

    }

在测试中,代码发送的电子邮件没有错误。上传到我的虚拟主机时,现在我在“提交”按钮上遇到此错误。谢谢您的帮助。

0 个答案:

没有答案