Using BCB to develop an email program with identity authentication function

Source: Internet
Author: User
Tags base64 mail

This article describes how to enhance the functionality of the NMSMTP control that sends e-mail in BCB, and to implement a mail-sending program with an identity authentication feature.

Keyword Esmtp,mime, identity authentication

Introduction

In order to suppress the spread of spam more effectively, most of the mail receiving and dispatching systems of most websites use the identity authentication function of ESMTP service. That is, the user needs to authenticate the user when sending the message, and if the account or password is wrong, the mail server will refuse to send the message. Borland C + + Builder 6 has a wealth of controls for developers to use, including, of course, mail-sending control NMSMTP, which is easy to use, but the only drawback is that it does not support the identity authentication feature when mail is sent. Through the analysis of the Mail sending protocol, the author designs the mail sending program with the identity authentication function on the basis of using the control.

ESMTP protocol Analysis

In order to realize the identity authentication function, the current ESMTP protocol has added a part of the content, this is the identity authentication. Below we take a look at this certification process, to the author in NetEase's mailbox as an example (where C represents the client, S represents the mail server):

(1) C:auth LOGIN

(2) s:334 Dxnlcm5hbwu6

(3) C:d3lxx2pux3nkx2nu

(4) s:334 Ugfzc3dvcmq6

(5) C: Password omitted

(6) s:235 Authentication Successful

Detailed Description:

(1) The client sends authentication instructions to the server.

(2) The server returns the Base64 code string, 334 means successful. The encoded string is decoded with "username:", which indicates that the client is required to send the user name.

(3) The client sends the BASE64 encoded user name string, which is "WYQ_JN_SD_CN".

(4) The server returns the Base64 code string, 334 means successful. The encoded string is decoded with "password:", which indicates that the client is required to send a user password.

(5) The client sends the BASE64 encoded password string, omitted here.

(6) The server returns the normal string, 235 means successful, indicating that the authentication successfully can send the mail.

MIME Base64 Encoding Interpretation

The average computer encoding a byte is 8bit,0--ff is 256 different 8bit combinations. The BASE64 code we're going to introduce now is 6bit per byte, with a total of 26 = 64 combinations. Each of these combinations corresponds to one character, these characters being "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567 89+/." "This means that every 3 normal encodings can be converted to 4 Base64 encodings, so what if the normal encoding that needs to be converted is not 3 integer multiples?" Base64 stipulates that the number of bytes after the digit is up to 0, and then a few characters to fill a few ' = ' number.

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.