Unable to send SMTP mail with .NET, network issue?
I am trying to send an smtp email through gmail's smtp server using the code below:
MailMessage message = new MailMessage("myEmail@gmail.com", "myEmail@purdue.edu", "Testing SMTP", "Test, yo");
SmtpClient client = new SmtpClient();
client.EnableSsl = true;
client.Host = "smtp.gmail.com";
client.Port = 587;
client.Credentials = new NetworkCredential("myEmail@gmail.com", "myPassword");
client.Send(message);
Using the same code my friend successfully sent me an email from another network, but .NET throws the error "No connection 开发者_如何学编程could be made because the target machine actively refused it 74.125.91.109:587". This has to be a network issue right?
My network admin claims there are no blocked outbound ports and my firewall is entirely off, what else could be causing this? I have tried Purdue's smtp server as well (smtp.purdue.edu), and it fails with the same message.
Turn off any antivirus program.
Regarding the test to Purdue, are you sure that they use port 587?
You should use port 465 for SSL according to this
Change the port to 465. It worked for me.
This may caused by McAfee Virus Blocks the Mass Mailing Worms. you can do the following:
1.Open the VirusScan Console by right clicking the VirusScan shield in the system tray and select VirusScan Console...
2.Double click the Access Protection item and open it.
3.Uncheck the Prevent Mass Mailing Worms from Sending Mail rule.
4.Click OK and close the VirusScan Console.
Hope this is helpless.
精彩评论