The remote certificate is invalid according to the validation procedure.

I'm trying to send an email from an ASP.NET (VB) web page via my hosting companies mail server, but getting the above error. They are telling me that they do not allow plain text mail and I must send using SSL, I have included enableSSL in my web.config setting as follows:

<mailSettings>
      <smtp from="from@my.com">
        <network host="server IP" port="587" userName="from@my.com" password="password" enableSsl="true"/>
      </smtp> 
    </mailSettings>
 

Open in new window


What am i missing?
BrianFordAsked:
Who is Participating?
 
BrianFordAuthor Commented:
Issue turned out to be that the .NET System.Net.Mail does not support 'ImplicitSSL' running on port 465.

I changed to System.Web.Mail (which unfortunately is deprecated) but still works

For anyone with the same issue, the following code worked for me:

 
Dim myMail As New MailMessage()

        myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver", pServer)
        myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", "465")
        myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", "2")

        'sendusing: value 2, for sending the message using the network.
        'smtpauthenticate: Specifies the mechanism used when authenticating to an SMTP service over the network.
        ' Possible values are:
        ' 0 = Do Not authenticate.
        ' 1 = Use basic clear-text authentication, When using this option you have to provide the user name and password through the sendusername and sendpassword fields.
        ' cdoNTLM, value 2. The current process security context is used to authenticate with the service.

        myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1") 'Use 0 for anonymous
        myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", pUserName)
        myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", pPwd)
        myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl", "true")
        myMail.From = pMailFrom
        myMail.[To] = pMailTo
        myMail.Subject = pSubject
        myMail.BodyFormat = MailFormat.Html
        myMail.Body = pBody

        'If pAttachmentPath.Trim() <> "" Then
        '    Dim MyAttachment As New MailAttachment(pAttachmentPath)
        '    myMail.Attachments.Add(MyAttachment)
        '    myMail.Priority = System.Web.Mail.MailPriority.High
        'End If

        SmtpMail.SmtpServer = pServer & ":465"

Open in new window

0
 
Peter HutchisonSenior Network Systems SpecialistCommented:
Are you using a Public SSL certificate on your web site for your domain (my.com)?
0
 
BrianFordAuthor Commented:
Not sure I understand where the cert should be?

Should the cert be on my development laptop (where my aspx page) is running? or are you referring to the mail server itself?

 I have no access to the mail server.
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
Peter HutchisonSenior Network Systems SpecialistCommented:
The certificate should be placed on the server, where the messages are being sent from.

If you are sending the mail messages from a development site on your laptop as well, then you should have a certificate installed there too linked to your computer's FQDN name. You can either get one from a internal CA, a self-signed cert (if allowed) or from a public CA service.
0
 
BrianFordAuthor Commented:
On my dev laptop I don't have full-blown IIS installed.

When I run the project in Visual Studio it's basically an IIS Express website running on 'localhost:random port' can a cert be created for that?
0
 
BrianFordAuthor Commented:
So,

I installed IIS on my local PC and have installed a Self-Signed cert, when I navigate to my local site using HTTPS, everything is good, but when I try to send the email I still get the same error
0
 
käµfm³d 👽Commented:
The key here is the word "remote" in the error message. Your local certificate situation should not have any bearing on this. You may need to verify what protocol suite(s) the hosting company's server uses. I would also check that they are using a valid certificate (as opposed to self-signed certificate) to secure their server. Maybe they have their own certificate authority and you have to update your server (or local machine) with their certificate authority info.
0
 
BrianFordAuthor Commented:
I thought that might be the case, their support is not being overly helpful :( their only suggestion to me was to include enableSSL='true" in my we-congig, which I did to no avail.

I would think their certs are valid as they are a large hosting company (www.hostdime.com) and I can't imagine I'm the only tryng to do this,. at this point I'm basically stumped :(
0
 
Peter HutchisonSenior Network Systems SpecialistCommented:
Looks like they offer SSL services http://www.hostdime.com/services/ssl-certificates/ 
Instructions on ordering a SSL cert here: http://www.hostdime.com/resources/order-ssl-via-core/ 
Instructions on installing cert here: http://www.hostdime.com/resources/install-ssl-via-whm/
0
 
käµfm³d 👽Commented:
Based on this page:

https://www.hostdime.com/resources/disable-plain-text-authentication/

...does it work if you use port 465?
0
 
BrianFordAuthor Commented:
Unfortunately not, but was worth a try :(  same error
0
 
BrianFordAuthor Commented:
actually, I had a typo in the port, 465 results in a timeout :(
0
 
BrianFordAuthor Commented:
This is what I'm using to send the email:

 Dim strFrom = "user@xxxx.com"
        Dim strTo = "me@mydoamin.com"
        Dim MailMsg As New MailMessage(New MailAddress(strFrom.Trim()), New MailAddress(strTo))

        MailMsg.BodyEncoding = Encoding.Default
        MailMsg.Subject = "Test Mail"
        MailMsg.Body = "This is a test email"
        MailMsg.Priority = MailPriority.Normal
        MailMsg.IsBodyHtml = True

        Dim SmtpMail As New SmtpClient
        Dim authenticationInfo As New Net.NetworkCredential("user@xxxx.com", "pwd here")

        SmtpMail.Host = "72.29.68.31"
        SmtpMail.Port = "465" ' also try 587
        SmtpMail.UseDefaultCredentials = False
        SmtpMail.EnableSsl = True
        SmtpMail.Credentials = authenticationInfo

        Try
            SmtpMail.Send(MailMsg)

        Catch ex As Exception
            Dim x As String = ex.Message
            lblInvalidCreds.Text = ex.Message
            lblInvalidCreds.Visible = True

        End Try

Open in new window

0
 
BrianFordAuthor Commented:
c
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.