I use gmail for various email notification redirects. You have to enable "less secure apps" for it to work in your gmail security settings. Every now and then you'll get notifications about your app trying to email out and you have to approve again. Also, please delete your password in your script if it's the valid one.
Problem sending by email
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);
3 answers
Sort by: Most helpful
-
-
Falcon IT Services 226 Reputation points
2022-01-15T01:50:58.74+00:00 Hello Sanel,
If you have access to Windows Server, it has an SMTP service you can enable. The setup instructions are on the link below, just skip past the SharePoint setup and look at the SMTP setup part. It's very easy to set up and very reliable.
https://www.falconitservices.com/sharepoint-2019-and-sql-server-installation-step-by-step/
Cheers,
Miguel Fra
https://www.falconitservices.com -
Jose Zero 576 Reputation points
2022-01-15T13:48:47.77+00:00 @Falcon IT Services , a Windows SMTP server, initially, will help just for local test. In production you need a fixed IP address and a Reverse DNS at provider, other than SMTP around web will not accept messages coming from your server