The Smpt command order is incorrect. Server Response: Error: need EHLO and AUTH first !, Smptehlo

Source: Internet
Author: User
Tags mailmessage smtpclient

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. 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.