I made an e-mailer in C#, but you have to enable less secure apps in google. Is there a way around this? If not, how do other apps send e-mails securely without being classified as a less-secure app?
private void SendButton_Click(object sender, EventArgs e) {
try {
SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
mail.From = new MailAddress(myUsername);
mail.To.Add(RecipientEmailBox.Text);
mail.Subject = SubjectField.Text;
mail.Body = MessageField.Text;
SmtpServer.Port = 587;
SmtpServer.Credentials = new
System.Net.NetworkCredential(myUsername, Login.password);
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
MessageBox.Show("Message Sent!");
} catch (Exception ex) {
MessageBox.Show(ex.ToString());
}
}
I tried researching ways to get around this, but I couldn't find anything.