السلام عليكم
الكود التالي لإرسال إيميل من صفحة aspx باستخدام C# :
MailMessage mm = new MailMessage(); mm.From = new MailAddress(FromMyEmail@gmail.com); mm.Subject = "لديك طلب صداقة جديد"; mm.Body = "okeyyyyyyyyyyyyyyyy"; mm.IsBodyHtml = true; mm.To.Add(new MailAddress(toEmail@hotmail.com)); NetworkCredential nc = new NetworkCredential(); nc.UserName = "FromMyEmail@gmail.com"; nc.Password = "MyPassword"; SmtpClient sc = new SmtpClient(); sc.Host = "smtp.gmail.com"; sc.EnableSsl = true; sc.UseDefaultCredentials = true; sc.Credentials = nc; sc.Port = 587; sc.Send(mm); mm.Dispose(); mm = null; nc = null; sc.Dispose(); sc = null;
ولكن عند تنفيذ الكود السابق تظهر المشكلة التالية :
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at
فما الحل ؟ أرجو المساعدة وجزاكم الله كل خير

