Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everyone.

I had a problem when I am going to send an e-mail.

I have the following code:

C#
this.m_oSmtpCliente.Host = this.m_sSMTPSERVER;
this.m_oSmtpCliente.Port = 587;
this.m_oSmtpCliente.EnableSsl = true;
this.m_oSmtpCliente.DeliveryMethod = SmtpDeliveryMethod.Network;
this.m_oSmtpCliente.UseDefaultCredentials = false;
this.m_oSmtpCliente.Credentials = new System.Net.NetworkCredential(this.m_sUser, this.m_sPass);

this.m_oSmtpCliente.Send(oMessage);


When I execute the last line. I crash and give me the following error:

C#
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 209.85.229.109:587
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)\r\n   at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)\r\n   at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)


I don´t know what happend. I view a lot of codes and I was the same things.

Thank you very much.
Posted
Comments
Henning Dieterichs 26-Oct-11 9:23am    
Which host do you use? "google.com" (which is wrong) or "smtp.google.com" (which should work)?
MiguelSanchezCuarental 26-Oct-11 9:29am    
No. I use smtp.gmail.com
I try using smtp.google.com, but it doesn´t work either.

A reverse lookup revealed that the IP you gave resolves to the FQDN ww-in-f109.1e100.net. Is this a machine on your network?
To check if the machine is reachable you can try to ping it. This only gives reliable information if ICMP is enabled in your network up to the machine you are trying to reach. Another test only works if there is a web server installed with at least on site enabled and bound to the above mentioned IP address. If the last statement is true you can try telnet 209.85.229.109 80. If the server is reachable from your computer the telnet command will connect.

If a telnet connect from your computer to server at port 587 fails and you have access to the server you can try to do a telnet connect on the server side. If this works then you know that there is some firewall on the way from your computer to the server that is blocking port 587.

If the connect at port 587 also fails on the server side you know that there is no service running on that port.

Please investigate and leave your finding in comment to this post.
Cheers!

—MRB
 
Share this answer
 
v3
Comments
Henning Dieterichs 26-Oct-11 9:37am    
If you are using Windows 7 (and I think Vista too) you have to enable the telnet-client or use putty ;)
Manfred Rudolf Bihy 26-Oct-11 9:58am    
Yes, I just found that out. Our company migrated to Windows7 a couple of weeks ago and I tell you I'm really pi**ed off. I want my XP client back. ;(
Thank god, we do most of our development stuff on servers dedicated to this task.
MiguelSanchezCuarental 26-Oct-11 9:43am    
I try to do it: "telnet telnet 209.85.229.109 80" and it doesn´t connect. But if I do ping to this ip, it received all the packets. What can i do?? What can I do for the server are reachable from my computer?
Manfred Rudolf Bihy 26-Oct-11 9:54am    
The IP you have mentioned has nothin to do with smtp.gmail.com. If you use nslookup command with smtp.gmail.com as a parameter the resolved IP is 74.125.43.108. What do you get when you enter: nslookup smtp.gmail.com?
MiguelSanchezCuarental 26-Oct-11 10:08am    
Sorry I change the ip of the post. This is the ip that it show when I wrote: nslookup smtp.gmail.com -> 74.125.65.108.
If I do telnet whit this ip and the port 25, it connect but I can´t use these port in mi program, because it show me the following error: "Server does not support secure connections"
I have just tested this on my system and it works correctly. The only difference being that I did not specify a port number in the SMTP client. Why have you selected port 587 in your test, when the defaults are 25 for non-SSL and 465 for SSL type mail?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900