I installed the latest version of the MailKit package, I figured out those methods in MailKit. I first tried to make the application complete for sending emails, but it could not be sent, so I later took the code from the internet and pasted the code. I researched and saw that I needed to make an SMTP server, so I could send emails through the program. I'm interested in how to make an SMTP server, if it can be free, or must be purchased, I tried "smtp.gmail.com", but it throws me this error "System.Net.Sockets.SocketException: 'A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because the connected host has failed to respond 142.250.102.108:587 '". I’ve searched the internet, and it’s paid almost everywhere
I tried to make a free google SMTP server, I found on youtube that it can, but again this error occurs to me, that server that I made works, I tried through the "SMTP online test", but only here it will not.
var message = new MimeMessage();
message.From.Add(new MailboxAddress("Test", "pandzicsanel7@gmail.com"));
message.To.Add(new MailboxAddress("Test", "pandzicsanel7@gmail.com"));
message.Subject = "How you doin'?";
message.Body = new TextPart("plain") { Text = "Test" };
using (var client = new SmtpClient())
{
client.Connect("smtp.gmail.com", 587, false);
client.Authenticate("pandzicsanel7@gmail.com", "");
client.Send(message);
client.Disconnect(true);