नई Google राजनीति https://googleonlinesecurity.blogspot.de/2014/04/new-security-measures-will-affect-older.html के अनुसार मैं एक ईमेल नहीं भेज सकता। Google के लिए "कम सुरक्षित ऐप्स" पर विचार किया जाता है जो OAuth 2.0 का उपयोग नहीं करता है।MailKit का उपयोग कर ईमेल कैसे भेजें?
मैं इस समस्या
var message = new MimeMessage();
message.From.Add(new MailboxAddress("Joey Tribbiani", "[email protected]"));
message.To.Add(new MailboxAddress("Mrs. Chanandler Bong", "[email protected]"));
message.Subject = "How you doin'?";
message.Body = new TextPart("plain"){ Text = @"Hey" };
using (var client = new SmtpClient())
{
client.Connect("smtp.gmail.com", 587);
////Note: only needed if the SMTP server requires authentication
client.Authenticate("[email protected]", "mypassword");
client.Send(message);
client.Disconnect(true);
}
हल करने के लिए MailKit उपयोग करना चाहते हैं लेकिन मैं An exception of type 'MailKit.Security.AuthenticationException' occurred in MailKit.dll but was not handled in user code.Additional information: Authentication failed.
मैं अपने सुरक्षा सेटिंग में बदलाव नहीं करना चाहती मिला है। क्योंकि मैं चाहता हूं कि सब कुछ सुरक्षित रहेगा। यही कारण है कि मैं System.Net.Mail
के बजाय मेलकिट का उपयोग करना शुरू कर रहा हूं, मैं इसे कैसे ठीक कर सकता हूं?
यह मेलकिट या सी # के बारे में नहीं है, यह Google के बारे में है। या तो आपके पास गलत पासवर्ड है या आपको खाते की सुरक्षा सेटिंग्स को बदलने की जरूरत है [जैसा कि यहां दिखाया गया है] (http://stackoverflow.com/questions/31231033/using-smtpclient-to-send-an-email-from-gmail) –
मेरा मानना है कि ऐसा इसलिए है क्योंकि आपको OAuth 2.0 के साथ कनेक्शन सेट करने की आवश्यकता है https://github.com/jstedfast/MailKit/blob/df7b0f5b9522ed355aa49cfbe56892031d65047f/FAQ.md#how-can-i-log-in-to-a- जीमेल-खाता-उपयोग-ओथ -20 –
असल में, कई कारण हैं कि जीमेल एक प्रमाणीकरण त्रुटि वापस कर सकता है भले ही पासवर्ड सही दिखाई देता है - एक बार पासवर्ड, दो-कारक प्रमाणीकरण [जैसा कि यहां वर्णित है] (https: // समर्थन। google.com/accounts/answer/6009563) –