Có lỗi khi dùng C# gởi mail thông qua SMTP gmail
0guest asked on 2016/01/23 13:13:41
Mình dùng SmtpClient để gửi email bằng account gmail nhưng luôn nhận lỗi:
Error: System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required.
Mình đảm bảo là thông tin username/password là đúng 100%. Kết nối vô SMTP của gmail tại địa chỉ: smtp.gmail.com:587
Error: System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required.
Mình đảm bảo là thông tin username/password là đúng 100%. Kết nối vô SMTP của gmail tại địa chỉ: smtp.gmail.com:587
Answers
1Hancock answer on 2016/01/17 11:57:18
Code mẫu gửi mail bằng C#
Và đảm bảo rằng bạn đã bật chức năng "Access For Less Secure Apps" ở link bên dưới
https://www.google.com/settings/security/lesssecureapps
var client = new SmtpClient("smtp.gmail.com", 587) { Credentials = new NetworkCredential("myusername@gmail.com", "mypwd"), EnableSsl = true }; client.Send("myusername@gmail.com", "myusername@gmail.com", "test", "testbody");
Và đảm bảo rằng bạn đã bật chức năng "Access For Less Secure Apps" ở link bên dưới
https://www.google.com/settings/security/lesssecureapps
Please login to answer this question