tags:

views:

87

answers:

1

Hi,

Why does this timeout?

Dim s As New SmtpClient
s.Host = "smtp.gmail.com"
s.Port = 465
s.EnableSsl = True
s.Timeout = 5000
s.Credentials = New NetworkCredential("[email protected]", "mypassword")

Dim m As New MailMessage
m.To.Add("[email protected]")
m.From = New MailAddress("[email protected]")
m.Body = "Test Message"
m.Subject = "Test Subject"
s.Send(m)

These settings come straight from my Outlook Express test setup, and it can send fine.

Set really long timeout = does nothing

Change port numbers to 587 or 25 = does nothing

One thought: Outlook Express has a "My server requires authentication" option, which I couldn't see an obvious equivalent for with SmtpClient. Could it be related to that?

Thanks in advance

Dave

--Trindaz on Fedang #vb.net-smtp

+1  A: 

Edit: You might need to add the following line: s.UseDefaultCredentials = False before the line starting with s.Credentials...

Do you have a firewall or some kind of anti-virus program running that might be blocking the connections?

A good place to start is to just do a simple connect from the command line.

telnet smtp.gmail.com 465

Note, depending on Windows version you might have to enable the telnet client first, see this link for details.

ho1
Now it gets weirder: s.UseDefaultCredentials = False 'kinda' works. The email gets through, but I still get a timeout error!Using HyperTerminal to open smtp.gmail.com 465 got me a blank screen which I couldn't type on. Running telnet smtp.gmail.com 465 straight from the command line got me a black screen which only sorta worked - typing moved the cursor along but no characers appeared.
Trindaz
UPDATE: setting timeout to 10 seconds avoids the timeout too. Thanks ho1!
Trindaz