Hello,
I have my own server, and I also used it for sending and receiving mail. After being hacked for the second time I gave up and signed up for gmail handling my email, using my own domain.
I also have two-step verification enabled, being hacked twice makes you cautious.
I want to send emails from my c# windows forms applications, so I've set up the app specific passwords. Still Google complains about secure connection or client not verified (5.5.1 Authentication required).
When doing a search you find a lot of advice to turn of protection for less secure apps, that's not what I want to do.
Thanks for your thoughts.
What I have tried:
var fromAddress = new MailAddress("myemail@mydomain.toplevel", "From Name");
var toAddress = new MailAddress("myemail@mydomain.toplevel", "To Name");
const string fromPassword = "abcdefghijklmnop";
const string subject = "test";
const string body = "This is a test!!";
var smtp = new SmtpClient
{
Host = "smtp.gmail.com",
Port = 587,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new NetworkCredential(fromAddress.Address, fromPassword),
Timeout = 20000
};
using (var message = new MailMessage(fromAddress , toAddress)
{
Subject = subject,
Body = body
})
{
smtp.Send(message);
}