Using GMail with ASP.Net: error: The remote certificate is invalid according to the validation proce

  • Thread starter Carmine [www.thetotalsite.it]
  • Start date
C

Carmine [www.thetotalsite.it]

Hi,
I'm trying to use gmail smtp server for an asp.net application, but when I
try to send an email I get this error:

"The remote certificate is invalid according to the validation procedure."

Of course, I have enabled ssl (enableSSL = true) and inserted the network
credentials for my account... but it still doesn't work.

How come does it happen?
How can I solve it?

I am using ASP.Net 2.0 and Google Apps.

Thanks in advance,
 
C

Carmine [www.thetotalsite.it]

I tried, but it still doesn't work :-(
As the article explains, I have set the port to 587 or 465, but now I get
this error:

A connection attempt failed because the connected party did not properly
respond after a period of time, or established connection failed because
connected host has failed to respond

....Why?

Bye,
 
S

sloan

Firewall or port block?

Something is stopping you.

Can you setup outlook/express to just test it?
 
C

Carmine [www.thetotalsite.it]

Can you setup outlook/express to just test it?

On Windows Mail it works fine.
Moreover, that problem appeared even when I tested the code on my local
machine through visual studio.

Anyhow, incredibly, I edited the code as follows:

Public Shared Function QuickSendEmail(ByVal subject As String, ByVal body As
String, ByVal isHTML As Boolean, ByVal recipient As String) As Boolean
Dim msg As System.Net.Mail.MailMessage = New
System.Net.Mail.MailMessage()
msg.To.Add(recipient)
msg.From = New MailAddress([email protected], "Staff di The Total
Site .it", System.Text.Encoding.UTF8)
msg.Subject = subject
msg.SubjectEncoding = System.Text.Encoding.UTF8
msg.Body = body
msg.BodyEncoding = System.Text.Encoding.UTF8
msg.IsBodyHtml = isHTML
msg.Priority = MailPriority.Normal

'Add the Creddentials
Dim client As SmtpClient = New SmtpClient()
client.Credentials = New System.Net.NetworkCredential(username,
password)
client.Port = 587 'or use 465
client.Host = "smtp.gmail.com"
client.EnableSsl = True

client.Send(msg)
Return True
End Function

And now, it works perfectly :-|
Curious. Before I was using web.config to set up smtp parameters, meh :|

Bye,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,821
Latest member
AleidaSchi

Latest Threads

Top