Witam,
chciałbym przy użyciu języka C# wysłać maila. Mam dwa konta pocztowe na gmail'u. Wykonuję zatem poniższy kod:
MailAddress from = new MailAddress("[email protected]");
MailAddress to = new MailAddress("[email protected]");
MailMessage mail = new MailMessage(from, to);
mail.Subject = "test";
mail.Body = "It is test mail";
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.Credentials = new NetworkCredential("[email protected]", "My Password to [email protected]");
smtp.EnableSsl = true;
smtp.Send(mail);
Po chwili oczekiwania wywala mi jednak wyjątek:
An unhandled exception of type 'System.Security.Authentication.AuthenticationException' occurred in System.dll Additional information: The remote certificate is invalid according to the validation procedure.
Macie pomysł co jest nie tak z moim kodem? Bo ja już naprawdę nie mam pojęcia. Wydaje mi się, że wszystko jest ok...