0
votes

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
1
Is the port 25 open on your web server ? Tool you can use: t1shopper.com/tools/port-scan (Must be executed from web server)Sage Pourpre
If this is running on a server and you are trying to SMTP out then you need to add an outbound rule for port 25 in the Firewall. If it SMTP in to this server then create an inbound rule for port 25. Normally Windows Server OS Firewall is strict so you have to open anything you want network access to.Michael Z.
@SagePourpre I tested as you suggested. smtp.secureserver.net is responding on port 25user3966883
I just changed my port from 25 to 80 & it started workinguser3966883

1 Answers

0
votes

I just changed my port from 25 to 80 & it started working