I have simple email sending application that is working in localhost. But when I try to accress with my web server than it throws exception error below. Is this error with my code or with server? I am using GoDaddy Hosting. How do I fix it?
System.Net.Mail.SmtpException: Failure sending mail. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: An attempt was made to access a socket in a way forbidden by its access permissions 68.178.213.37:25 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) --- End of inner exception stack trace --- at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6) at System.Net.PooledStream.Activate(Object owningObject, Boolean async, GeneralAsyncDelegate asyncCallback) at System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback) at System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) at System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint) at System.Net.Mail.SmtpTransport.GetConnection(ServicePoint servicePoint) at System.Net.Mail.SmtpClient.GetConnection() at System.Net.Mail.SmtpClient.Send(MailMessage message) --- End of inner exception stack trace --- at System.Net.Mail.SmtpClient.Send(MailMessage message) at mass_mail.confirmationMail() in G:\PleskVhosts\healthsaviour.com\httpdocs\mass-mail.aspx.vb:line 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("[email protected]")
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