1
votes

I am trying to send mail using smtp server but i am getting following Exception. Please give me some advice..

System.Net.Mail.SmtpException: Failure sending mail.
---> System.Net.WebException: Unable to connect to the remote server
---> System.Net.Sockets.SocketException: A socket operation was attempted to an unreachable network 184.xx.xxx.xx:25
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
--- End of inner exception stack trace ---
at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket 6, Int32 timeout)
at System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback)
at System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback)
at System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncD elegate asyncCallback, Int32 creationTimeout)
at System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port)
at System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port)
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 testEmail.Module1.Main() in E:\testEmail\testEmail\Module1.vb:line 17

2

2 Answers

0
votes

From this messagge

A socket operation was attempted to an unreachable network 184.xx.xxx.xx:25

it seems that you cannot reach the SMTP address.

Check your internet connection and then check if the address is correct. A Ping to the address or a tracerout can help you understand why you cannot contact the server, if the address is correct

0
votes

The message tells me that your webserver has problems connectiong to your SMTP server. Are you sure the SMTP address is right?

Remember that some SMTP-servers need logon

Also some SMTP servers will not let you connect if your use a different IPS

I would change the SMTP to the one your ISP has. You can try to connect to the SMTP with Telnet to check your connection

telnet YourSmtpAddress 25