Click here to Skip to main content
15,885,952 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Server Error in '/email' Application.

The remote certificate is invalid according to the validation procedure.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.

Source Error:


Line 35: smtp.EnableSsl = true;
Line 36: smtp.Send(mail);
Line 37:
Posted
Comments
Nandakishore G N 8-Feb-13 1:11am    
post the code
Member 9794156 8-Feb-13 2:38am    
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Mail;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{

MailMessage mail = new MailMessage();
mail.To.Add("ex1@gmail.com");
mail.To.Add("ex2@gmail.com");
mail.From = new MailAddress("admin1@gmail.com");
mail.Subject = "Email using Gmail";

string Body = "Hi, this mail is to test sending mail"+
"using Gmail in ASP.NET";
mail.Body = Body;

mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.UseDefaultCredentials = false;
smtp.Credentials = new System.Net.NetworkCredential
("admin1@gmail.com", "password");
smtp.EnableSsl = true;
smtp.Send(mail);


}

}
joe_j 8-Feb-13 1:55am    
please post the entire code that sends the email including all the smtp settings
Member 9794156 8-Feb-13 2:38am    
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Mail;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{

MailMessage mail = new MailMessage();
mail.To.Add("ex1@gmail.com");
mail.To.Add("ex2@gmail.com");
mail.From = new MailAddress("admin1@gmail.com");
mail.Subject = "Email using Gmail";

string Body = "Hi, this mail is to test sending mail"+
"using Gmail in ASP.NET";
mail.Body = Body;

mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.UseDefaultCredentials = false;
smtp.Credentials = new System.Net.NetworkCredential
("admin1@gmail.com", "password");
smtp.EnableSsl = true;
smtp.Send(mail);


}

}
Nandakishore G N 8-Feb-13 3:31am    
if the above code is not wrong..then it is the problem of the gateway...try it using the datacard or any personal means..it works

1 solution

insert code in web.config
XML
<system.net>
    <settings>
      <servicePointManager checkCertificateName="true" checkCertificateRevocationList="false" />
    </settings>
  </system.net>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900