caltrop
caltrop

Reputation: 364

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("[email protected]", "[email protected]", "Testing SMTP", "Test, yo");
SmtpClient client = new SmtpClient();
client.EnableSsl = true;
client.Host = "smtp.gmail.com";
client.Port = 587;
client.Credentials = new NetworkCredential("[email protected]", "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.

Upvotes: 2

Views: 3365

Answers (4)

Da Xiong
Da Xiong

Reputation: 135

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.

Upvotes: 0

Liza V.
Liza V.

Reputation: 1

Change the port to 465. It worked for me.

Upvotes: 0

Lee
Lee

Reputation: 144136

You should use port 465 for SSL according to this

Upvotes: 0

Hans Olsson
Hans Olsson

Reputation: 55009

Turn off any antivirus program.

Regarding the test to Purdue, are you sure that they use port 587?

Upvotes: 4

Related Questions