I am attempting to send an email, although an error message returned saying:
The remote certificate is invalid according to the validation procedure
My code is as follows:
static void sendEmail()
{
var fromAddress = new MailAddress("xxxxxxxx@xxxxxxxx", "xxxxxxx");
var toAddress = new MailAddress("xxxxxxxx@xxxxxxxx", "xxxxxxxx");
const string fromPassword = "xxxxxxxxxxxx";
const string subject = "xxxxxxxxxxxxxxxxxxxxx";
var smtp = new SmtpClient
{
Host = "mailserver",
Port = 587,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new NetworkCredential("username", fromPassword)
};
using (var message = new MailMessage(fromAddress, toAddress)
{
Subject = subject,
Body = bodyglobal
})
{
smtp.Send(message);
}
}
try setting
I had this issue a few weeks ago and this was the fix. If your program doesnt need/use SSL then a smtpexecption will fire with that error message.