I was able to send emails with local smtp but when trying to send with gmail, it isnt working.
ERROR:
"The server rejected the sender address. The server response was: 530 5.7.0
Must issue a STARTTLS command first. pj7sm14546972pbb.96 - gsmtp\r\n"
C#:
public static void SendEmail()
{
MailMessage mailMsg = new MailMessage();
SmtpClient smtpClient = new SmtpClient();
mailMsg.From = "donotreply@admin.com"; //also tried smtpusername here
mailMsg.To = strToAddress;
mailMsg.Subject = strSubject;
mailMsg.Body = strBody;
smtpClient.Port = 587;
smtpClient.EnableSsl = true;
smtpClient.Credentials = new NetworkCredential(smtpusername, smtppassword);
//smtpusername & smtppassword are valid gmail credentials
SmtpMail.SmtpServer = "smtp.gmail.com";
SmtpMail.Send(mailMsg);
}