The Smpt command order is incorrect. Server Response: Error: need EHLO and AUTH first !, Smptehlo
I just found that I couldn't use emails sent from my previous QQ mailbox. I found the following reason: I was not added (EnableSsl SSL encrypted connection), and I suddenly felt very bad, in the past, QQ mail had no such restriction. It may have been recently added.
Well, let's just start from scratch and take care of the newcomers O ~
1. First enable "POP3/SMTP Service" in the QQ mailbox"
2. Obtain the "authorization code"
After you activate the service in the previous step, you will be prompted with an "authorization code". If you have activated the service, you can check it.
3. Encoding
SmtpClient smtpClient = new SmtpClient ();
SmtpClient. EnableSsl = true;
SmtpClient. usedefadefacredentials = false;
SmtpClient. DeliveryMethod = SmtpDeliveryMethod. Network; // specify the email sending Method
SmtpClient. Host = smtpServer; // specify the SMTP server
SmtpClient. Credentials = new System. Net. NetworkCredential (userFrom, userPassword); // user name and authorization code
// Send email settings
MailMessage mailMessage = new MailMessage (userFrom, MailTo); // sender and recipient
MailMessage. Subject = mailSubject; // Subject
MailMessage. Body = "content ";
MailMessage. BodyEncoding = Encoding. UTF8; // body Encoding
MailMessage. IsBodyHtml = true; // set it to HTML Format
MailMessage. Priority = MailPriority. Low; // Priority
Note: you must first set EnableSsl and usedefacrecredentials, and then instantiate the Credentials.