Reputation: 35
protected void BtnSubmit_Click(object sender, EventArgs e)
{
GetAllUsersName U = new GetAllUsersName();
string Email = U.GetUSEREmail(TxtEmailPass.Text);
SmtpClient mySmtpClient = new SmtpClient("smtp.gmail.com", 587);
mySmtpClient.EnableSsl = true;
mySmtpClient.UseDefaultCredentials = false;
mySmtpClient.Credentials = new NetworkCredential("[email protected]", "Pro123456789");
mySmtpClient.EnableSsl = true;
MailMessage msg = new MailMessage("[email protected]", Email, "Password", "your password is:");
mySmtpClient.Send(msg);
}
This is my code, but it keeps telling me:
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required.
Upvotes: 2
Views: 76
Reputation: 32713
Your code looks fine. If this is a new account, make sure you change your password - at least once. Gmail may be looking for you to change password.
Upvotes: 1