Thursday, March 29, 2012

smtp error: unable to connect to remote server...No connection could be made because the t

Hi,

I got "InnerException: Unable to connect to remote server"..."No
connection could be made because the target machine actively refused
it" when I attempted to send an email through my Intranet app that is
written in asp.net 2.0. The smtp server is a local server and it uses
Port 25. The Authentication is set to Anonymous Access. Here's my
code:

<system.net>
<mailSettings>
<smtp>
<network host="10.162.22.72" />
</smtp>
</mailSettings>
</system.net>

Protected Sub SendEmail_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles SendEmail.Click
Const ToAddress As String = "someone@dotnet.itags.org.somewhere.com"
Dim mm As New MailMessage(UsersEmail.Text, ToAddress)
mm.Subject = Subject.Text
mm.Body = Body.Text
mm.IsBodyHtml = False
Dim smtp As New SmtpClient
smtp.Send(mm)
End Sub

In the <network host.. /> section, I did not specify a username and
password because I set the smtp server authentication mode is set to
Anonymous Access. Can someone please tell me what I did wrong? I
couldn't find anything on the Web that could point me in the right
direction.

In the Access tab:
Authentication: Anonymous Access
Connection: All except the list below. There's nothing in the list.
Relay Restriction: Only the list below. In the list below, I granted
access to my development PC using its IP address. I also granted
access to 127.0.0.1 as well as checking the "Allow all computers which
successfully authenticate to relay, regardless of the list above.

In the Security tab:
Grant operating permission to these windows user accounts:
Administrator, NT AUTHORITY\LOCAL SERVICE, NT AUTHORITY\NETWORK
SERVICE.

Thank you for you help in advance,
Jon

Hi Jon,

Homer Duff:

I also granted
access to 127.0.0.1 as well as checking the "Allow all computers which
successfully authenticate to relay, regardless of the list above.

Based on my understanding, you don't need to specify the resctriction list, try removing it. And changing network host in web.config file to localhost. The problem is probably because you enabled loopback address on one end and enabled another address on the other end.

0 comments:

Post a Comment