1

I'm trying to send a couple of emails using google SMTP server. I've been researching how to and have found plenty of articles on stackoverflow and other resources where people successfuly send email - I haven't been able to do so. Here's the code I've been using trying to contact the SMTP server:

var secureString = new SecureString(); foreach (char c in "password") { secureString.AppendChar(c); } var client = new SmtpClient("smtp.gmail.com", 587) { UseDefaultCredentials = false, DeliveryMethod = SmtpDeliveryMethod.Network, Credentials = new NetworkCredential("[email protected]", secureString), EnableSsl = true }; client.Send("[email protected]", "[email protected]", asdf", "asdf"); 

The exception I'm getting is saying that it's unable to contact the remote server. The innermost exception says:

"An attempt was made to access a socket in a way forbidden by its access permissions 64.233.161.109:587"

Any suggestions on what else to try?

I've tried this on three different network to ensure that this isn't a firewall issue. Using my cell phone as a hotspot I've had the same problen, which should mean that it isn't a company firewall.

4
  • Can you try port 465? Commented Feb 26, 2015 at 10:00
  • Yes, it doesn't work either albeit with a different innerexception message: "No connection could be made because the target machine actively refused it 74.125.205.109:465". I'm not sure if this is "better" and that it's implying that something else is wrong, e.g. my credentials. Commented Feb 26, 2015 at 10:11
  • It's worse. It means there is no listener at that port. Commented Feb 26, 2015 at 10:14
  • take look to my answer. I have the same problem one month ago and it was resolved as i have mentioned Commented Feb 26, 2015 at 10:15

2 Answers 2

1

It is about a configuration on your gmail account to allow access with your @dress and your password from other application. So you have to activate it.

Sign up to request clarification or add additional context in comments.

1 Comment

What configuration would that be? Allowing POP/IMAP is a suspect but doesn't do anything in my case...
0

I am answering my own question, which might be a specific answer for my machine but could help others in a similar situation.

My issue was my antivirus software, Macfee, which helpfully decided that trying to send email trafic is probably a virus and thus quietly dropped the trafic from my application. I checked pretty much everything else as I thought that an antivirus would never care about ports (typically a firewall feature imo) but I guess some do...

Anyway the issue is resolved and if anyone else has got the same issue and can't explain it, check your anti virus software...

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.