Reputation: 21742
I've got code as follows:
var smtpClient = new SmtpClient("my.mail.server");
smtpClient.Send(mailmessage);
however the send method call fails with a "the remote machine actively refused" exception message. I know that there's no firewall blocking cuz I can telnet to the same addresse and manually work the Smtp protocol through with the server. I know the code is working cuz I can get a connection to a different port than the default 25. There's no software firewall blocking the transmission.
When wiresharking I can see the packages being set when telnet'ing and I can see that nothing leaves my machine when I try with the code. So it's a safe assumption that the problem is on my machine and has nothing to do with the network.
Basically I can connect to the address with everything else than .NET code which leads me to my problem potentially being a configuration problem but I lack ideas of where and what I'd need to configure differently. Any suggestions to a possible cause?
EDIT: In a project with only the two line that sends the mail I get the same problem. When trying to establish a TCP connection through code I get the same problem so I know it's nothing to do with the SMTP protocol (or authentication) the problem is the TCP socket connection attempt being blocked but I still have no clue why
Upvotes: 0
Views: 4919
Reputation: 21742
Well It would seem the system administrators had forgotten that they had put two firewalls in place... (only costed me two days or so) when it comes to port 25 our antivirus also includes antispam. Thanks for the thoughts and suggestions everyone
Upvotes: 1
Reputation: 12216
What OS are you running? I'll now state the obvious and ask if you have verified that Windows Firewall is off?(I see your software firewall comment but this tends to get overlooked)
Also try and verify the port being used as we have to use ours like so -->
SmtpClient smtpClient = new SmtpClient("OURMAIL",25);
smtpClient.Send(message);
Upvotes: 3
Reputation: 24522
Have you checked the configuration of the SMTP server? It could be configured to not allow anonymous connections or to deny your IP address.
Can you send an email through the SMTP server using another client e.g. Outlook?
Upvotes: 1