Why does System.Web.Mail work in development and not in production?

H

Homer

Hi,

I've posted this question before but didn't get anywhere with it.
Please help me out if you know of a solution for it.

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. I tried
pointing to the SMTP gateway on my Exchange server and I ran into the
same problem. My organization uses Mcafee 8.5i. Does that have to do
with anything? 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 = "(e-mail address removed)"
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.


Thanks,
Jon
 
M

Mark Rae [MVP]

My bad, typo. I'm using System.Net.Mail.

Grrrrrrr....! ;-)
Unfortunately, I don't have access to the McAfee VirusScan Console
to add the W3wp.exe to the exclusion list. Do you know if that would fix
it?

Yes, almost certainly...
 
J

Juan T. Llibre

re:
!> I got "InnerException: Unable to connect to remote server".

Can you ping 10.162.22.72 from the box which hosts the mail code ?
 
H

Homer

re:
!> I got "InnerException: Unable to connect to remote server".

Can you ping 10.162.22.72 from the box which hosts the mail code ?













- Show quoted text -

Yes I could ping it. Grrrrrrrrrr...
 
K

Kevin Spencer

The problem is almost certainly one of security. SMTP is a network protocol
that uses a specific TCP port (usually 25) to send a message from a client
application to an SMTP server. The SMTP server then sends the message to the
end recipient, usually a POP3 server like Exchange. There are many security
issues involved. First, the SMTP server must be configured correctly to
allow the client to send a message to it. This involves configuring the
Authentication correctly on the SMTP server, and the client using the
correct Authentication method to connect. It also involves configuring Relay
permissions correctly on the SMTP server.

If the SMTP server is not on the same machine as the client, it also
involves the network security between the machines on the network, whether
it is a private network or a public one. The IP address in your MailSetting
section indicates that the SMTP server is on a private network, and I will
assume that the client application is on a machine in the same private
network. Therefore, Firewall software on either the client machine or SMTP
server machine may need to be configured to allow the SMTP traffic.

Assuming that the messages is received by the SMTP server, the SMTP server
can be configured to send the message by any of several means. Inside a
private network, this generally requires that the SMTP server be mapped to a
public IP address using NAT (Network Address Translation), or that it be
configured to use another SMTP server as a "Smart Host." If the SMTP server
has a public IP address, it must be allowed by the network Firewall to pass
the message through. If it uses a Smart Host, the Smart Host must be
configured to allow messages from the client SMTP server, and allowed by the
network Firewall to pass the message through.

I hope you have a network administrator handy to help you figure out what
the problem is.

--
HTH,

Kevin Spencer
Microsoft MVP

DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net
 
H

Homer

The problem is almost certainly one of security. SMTP is a network protocol
that uses a specific TCP port (usually 25) to send a message from a client
application to an SMTP server. The SMTP server then sends the message to the
end recipient, usually a POP3 server like Exchange. There are many security
issues involved. First, the SMTP server must be configured correctly to
allow the client to send a message to it. This involves configuring the
Authentication correctly on the SMTP server, and the client using the
correct Authentication method to connect. It also involves configuring Relay
permissions correctly on the SMTP server.

If the SMTP server is not on the same machine as the client, it also
involves the network security between the machines on the network, whether
it is a private network or a public one. The IP address in your MailSetting
section indicates that the SMTP server is on a private network, and I will
assume that the client application is on a machine in the same private
network. Therefore, Firewall software on either the client machine or SMTP
server machine may need to be configured to allow the SMTP traffic.

Assuming that the messages is received by the SMTP server, the SMTP server
can be configured to send the message by any of several means. Inside a
private network, this generally requires that the SMTP server be mapped to a
public IP address using NAT (Network Address Translation), or that it be
configured to use another SMTP server as a "Smart Host." If the SMTP server
has a public IP address, it must be allowed by the network Firewall to pass
the message through. If it uses a Smart Host, the Smart Host must be
configured to allow messages from the client SMTP server, and allowed by the
network Firewall to pass the message through.

I hope you have a network administrator handy to help you figure out what
the problem is.

--
HTH,

Kevin Spencer
Microsoft MVP

DSI PrintManager, Miradyne Component Libraries:http://www.miradyne.net












- Show quoted text -

My organization uses Mcafee 8.5i and when I unchecked "block" on "mass
mailing..." I was able to send send messages through. I found a
suggestion from McAfee to add "W3wp.exe" to the exclusion list of port
25 but that turned out to be a dud. I finally unchecked the block and
it worked. I have to check with my ePO guy to see if there is any
security risk in unblocking port 25 altogether.

Thank you everybody for your invaluable help. Please keep the
suggestion coming. The more suggestions I get the more options I have
to explore.

Jon
 
M

Mark Rae [MVP]

My organization uses Mcafee 8.5i and when I unchecked "block" on "mass
mailing..." I was able to send send messages through.

Yes indeed.
I found a suggestion from McAfee to add "W3wp.exe" to the exclusion list
of port
25 but that turned out to be a dud.

Curious. I have a client with that exact same issue, and adding w3wp.exe in
"Access Protection Properties" fixed it...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,150
Members
46,697
Latest member
AugustNabo

Latest Threads

Top