我正在尝试发送电子邮件,尽管返回了一条错误消息:
根据验证程序,远程证书无效
我的代码如下:
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);
}
}