Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Friday, August 2, 2013 9:22 PM
I've seen this problem everywhere searching...but haven't been able to resolve it.
- I have created a simple console application to test smtp on a WinXP Pro box.
- First I enabled port 25, then I just disabled the Windows firewall altogether.
- There is no McAffee installed that would block the port.
- I also attempted to telnet and was refused.
- I ping the mail server and it responds correctly
Here's the code sample..
static void Main(string[] args)
{
MailMessage msg = new MailMessage("[email protected]", "[email protected]", "test", "This is a test");
SmtpClient client = new SmtpClient("smtp.domain.com");
System.Net.NetworkCredential("user", "pass");
System.Net.NetworkCredential cred = new NetworkCredential("user", "pass");
client.Credentials = CredentialCache.DefaultNetworkCredentials;
try
{ client.Send(msg); }
catch (SmtpException ex)
{
Console.WriteLine(ex.ToString());
Console.ReadKey();
}
Here's the error it throws:
{System.Net.Mail.SmtpException: Failure sending mail. > System.Net.WebException: Unable to connect to the remote server > System.Net.Sockets.SocketException: 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 123.45.789.123: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& abortSocket6, 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, GeneralAsyncDelegate 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 mailTest.Program.Main(String[] args) in C:\mailTest\mailTest\mailTest\Program.cs:line 25}
I'm at a loss.
thanks
All replies (7)
Tuesday, August 13, 2013 4:32 PM âś…Answered | 2 votes
McAfee was blocking port 25.
Got admin rights and disabled mass emailing setting.
Thanks everyone.
Friday, August 2, 2013 9:50 PM | 1 vote
If you cannot telnet to port 25 on smtp.domain.com, you will be unable to use smtp.domain.com to send mail.
Karl
When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer
My Blog: http://unlockpowershell.wordpress.com
My Book: Windows PowerShell 2.0 Bible
My E-mail: -join ("6B61726C6D69747363686B65406D742E6E6574"-split"(?<=\G.{2})",19|%{[char][int]"0x$_"})
Saturday, August 3, 2013 11:52 PM
Well, I opened that port up in the XP Firewall...
Shouldn't that have fixed the problem?
Also, I shut the firewall off altogether.
Thanks
Doug
Sunday, August 4, 2013 12:51 AM
On whose side did you open Port 25? Client, Server or both?
As a test with Tellnet failed, this is clearly nto a programming issue. It is a server-administration issue.
Let's talk about MVVM: http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/b1a8bf14-4acd-4d77-9df8-bdb95b02dbe2 Please mark post as helpfull and answers respectively.
Sunday, August 4, 2013 3:09 AM
I find some threads which are similar with your question, you can refer to the below threads to get more help:
http://stackoverflow.com/questions/3238277/asp-net-smtpclient-unable-to-connect-to-the-remote-server
http://stackoverflow.com/questions/5899180/sending-an-email-through-gmail-smtp-server-ssl
If my post is helpful,please help to vote as helpful, if my post solve your question, please help to make it as answer. My sample
Tuesday, April 26, 2016 4:22 PM
McAfee VS Enterprise always gets me, too. Thank you.
Monday, July 27, 2020 11:42 AM
I think this is a resource problem. you not dispose disposable object
try this code:
using(MailMessage msg = new MailMessage("[email protected]", "[email protected]", "test", "This is a test")){
using(SmtpClient client = new SmtpClient("smtp.domain.com")) {
System.Net.NetworkCredential("user", "pass");
System.Net.NetworkCredential cred = new NetworkCredential("user", "pass");
client.Credentials = CredentialCache.DefaultNetworkCredentials;
try
{ client.Send(msg); }
catch (SmtpException ex)
{
Console.WriteLine(ex.ToString());
Console.ReadKey();
} }}