VB.net邮件发送在localhost中工作但在Web服务器中出错

时间:2016-05-24 14:54:02

标签: asp.net vb.net email smtp

我有简单的电子邮件发送应用程序在localhost中工作。但是当我尝试使用我的Web服务器时,它会抛出下面的异常错误。这是我的代码或服务器的错误?我正在使用GoDaddy Hosting。我该如何解决?

  

System.Net.Mail.SmtpException:发送邮件失败。 ---> System.Net.WebException:无法连接到远程服务器---> System.Net.Sockets.SocketException:尝试以System.Net上的System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot,SocketAddress socketAddress)的访问权限68.178.213.37:25禁止访问套接字。 .ServicePoint.ConnectSocketInternal(Boolean connectFailure,Socket s4,Socket s6,Socket& socket,IPAddress& address,ConnectSocketState state,IAsyncResult asyncResult,Exception& exception)---内部异常堆栈跟踪结束---在System.Net.ServicePoint System.Net.PooledStream.Activate上的System.Net.PooledStream.Activate(Object owningObject,Boolean async,GeneralAsyncDelegate asyncCallback)中的.GetConnection(PooledStream PooledStream,Object owner,Boolean async,IPAddress& address,Socket& abortSocket,Socket& abortSocket6) System.Net上的System.Net.ConnectionPool.GetConnection(Object owningObject,GeneralAsyncDelegate asyncCallback,Int32 creationTimeout)中的(Object owningObject,GeneralAsyncDelegate asyncCallback) System.Net.Mail.SmtpClient.Send上的System.Net.Mail.SmtpClient.GetConnection()处的System.Net.Mail.SmtpTransport.GetConnection(ServicePoint servicePoint)上的.sail.SmtpConnection.GetConnection(ServicePoint servicePoint)。(MailMessage消息) )---内部异常堆栈跟踪的结束---在G:\ PleskVhosts \ healthsaviour.com \ httpdocs \ mass-mail.aspx中的mass_mail.confirmationMail()处的System.Net.Mail.SmtpClient.Send(MailMessage消息)处.vb:第24行

Imports System.Data
Imports System.IO
Imports System.Net.Mail
Imports MySql.Data.MySqlClient
Partial Class mass_mail
    Inherits System.Web.UI.Page

    Private Sub sendBulk_Click(sender As Object, e As EventArgs) Handles sendBulk.Click
        confirmationMail()
    End Sub

    Private Sub confirmationMail()
        Try
            Dim mail As New MailMessage
            Dim SmtpServer As New SmtpClient()
            mail.From = New MailAddress("support@healthsaviour.com")
            mail.To.Add(TextBox1.Text)
            mail.Subject = "Order No"
            mail.Body = "Hi"
            mail.IsBodyHtml = True
            SmtpServer.Port = 25
            SmtpServer.Credentials = New System.Net.NetworkCredential("email", "password")
            SmtpServer.Host = "smtp.secureserver.net"
            SmtpServer.Send(mail)
        Catch ex As Exception
            Response.Write(ex)
        End Try
    End Sub
End Class

1 个答案:

答案 0 :(得分:0)

我刚刚将我的端口从25改为80&它开始工作了