I've been trying for a whlie on this, and have so far been failing miserably. My most recent attempt was lifted from this stack code here: http://stackoverflow.com/questions/704636/sending-email-through-gmail-smtp-server-with-c, but I've tried all the syntax I could find here on stack and elsewhere. My code currently is:
var client = new SmtpClient("smtp.gmail.com", 587)
{
Credentials = new NetworkCredential("[email protected]", "mypass"),
EnableSsl = true
};
client.Send("[email protected]","[email protected]","Test", "test message");
Running that code gives me an immediate exception "Failure sending mail" that has an innerexeption "unable to connect to the remote server".
If I change the port to 465 (as gmail docs suggest), I get a timeout every time.
I've read that 465 isn't a good port to use, so I'm wondering what the deal is w/ 587 giving me failure to connect. My user and pass are right. I've read that I have to have POP service setup on my gmail account, so I did that. No avail.
I was originally trying to get this working for my branded GMail account, but after running into the same problems w/ that I thought going w/ my regular gmail account would be easier... so far that's not the case.
Thanks for the help. Paul