C # Experience in ESMTP-based email sending Systems

Source: Internet
Author: User

Friends who have used the C # built-in SMTP class probably know that when using it to send emails, sometimes there are always inexplicable errors, sometimes it can be sent successfully, sometimes it is said that the user account verification fails, even if you have set the account verification information, the problem persists, especially when you use a QQ mailbox (as if SMTP is normal for 163). Basically, it is impossible to use an SMTP object to send emails, later, I found some materials and said that the QQ protocol seems to be ESMTP, that is, the enhanced SMTP protocol. I don't know if it is. There are many people who use QQ emails anyway, the issue of sending is more prominent.

In particular, my software "QQ number collection and email sending system" has been using SMTP class to handle mail sending. The problem that the customer reported that QQ mail was not successfully sent is particularly prominent, however, I didn't know how to deal with this problem at the time. I found a lot of materials at night, and the problem remained a headache. Let's take a look at the interface of my mail sending software first.
This software has now implemented the ESMTP protocol Batch Sending function. The test showed that 163 also supports ESMTP protocol. It is estimated that most SMTP providers support this interface, for them, this is a safer and less spam protocol, as if there are some "real-name" rules that we call everyday. Unlike SMTP mail, ESMTP sends TCP/IP commands to the server in a stream mode to obtain the interactive response mode. For example, to connect to the SMTP server, first, use the following code to connect. // Connect to the network
Try
{
Tc = new TcpClient (mailserver, mailserverport );
}
Catch (Exception e)
{
Errmsg = e. ToString ();
Return false;
}

Ns = tc. GetStream ();
  /// <Summary>
/// Receive the SMTP server response
/// </Summary>
Protected string RecvResponse ()
{
Int StreamSize;
String ReturnValue = "false ";
Byte [] ReadBuffer = new byte [4096];

Try
{
StreamSize = ns. Read (ReadBuffer, 0, ReadBuffer. Length );
}
Catch
{
Errmsg = "network connection error ";
Return ReturnValue;
}

If (StreamSize = 0)
{
Return ReturnValue;
}
Else
{
& Nb

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.