Original SMTP command code and working principle

Source: Internet
Author: User
Tags mx record
Www. linuxforum. netJepheWu (2001-04-2118:16:42) 1. SMTP works in two situations: one is the transmission of email from the client to the server, and the other is the transmission from one server to another. SMTP is a request response protocol. commands and responses are based on ASCII text and end with CR and LF characters. The response includes one that indicates that SMTP is returned.

Http://www.linuxforum.net Jephe Wu (18:16:42)
                  
1. SMTP works in two situations: one is to transfer an email from the client to the server, and the other is to transfer it from one server to another.
Server
2. SMTP is a request/response protocol. commands and responses are based on ASCII text and end with CR and LF characters. The response includes a response
Three-digit code of the return status
3. SMTP listens for connection requests on TCP port 25
4. connection and sending process:

A. establish a TCP connection
B. The client sends the HELO command to identify the sender, and then the client sends the MAIL command
If the server correctly wishes to use OK as a response, it indicates that it is ready to receive
C. The client sends the RCPT command to identify the recipient of the email. there can be multiple RCPT lines.
The server indicates whether the email is willing to be accepted by the recipient.
D. After the negotiation ends, send an email and use the command DATA to send it.
E. end the input content and send it together.
F. end sending and exit with the QUIT command.


5. Two other commands:
VRFY --- used to verify whether a given user's email address exists and receive detailed information about the user.
EXPN --- used to expand the mail list.

6. mail routing process:
The SMTP server routes emails based on the domain name of the recipient in the 'domain name service DNS. The SMTP server is based on the MX record in the DNS
The MX record registers the domain name and the relevant SMTP relay host. all emails in this domain should be sent to the host.

If the SMTP server mail.abc.com receives a letter to be sent to the shuser@sh.abc.com:

A. Sendmail requests DNS to provide the CNAME record of host sh.abc.com. If yes, if CNAME is sent to shmail.abc.com
Request the CNAME record of shmail.abc.com until no
B. assume that the CNAME is sent to shmail.abc.com, and then the DNS of The sendmail request @ abc.com domain gives the MX record of shmail.abc.com,
Shmail MX 5 shmail.abc.com
10 shmail2.abc.com
C. Sendmail finally requests DNS to give the record of shmail.abc.com, that is, IP address. if the returned value is 1.2.3.4
D. Sendmail connects to 1.2.3.4 and sends the mail to the shuser@sh.abc.com to the SMTP background program on this server 1.2.3.4

7. SMTP basic command set:

Command description
------------------------------
HELO identifies a user to the server
The sender can cheat and lie, but generally the server can detect it.

MAIL initialization email transmission
Mail from:
RCPT identifies a single email recipient, often behind the MAIL command
Multiple rcpt:
After one or more RCPT commands, DATA indicates that all email recipients have been identified, and DATA transmission is initiated to end.
VRFY is used to verify whether the specified user or email address exists. This command is often disabled by the server for security reasons.
EXPN verifies whether the specified mailbox list exists and expands the mailbox list.
HELP query commands supported by the server
No NOOP operation, the server should respond OK
QUIT end session
RSET resets the session and the current transmission is canceled.
--------------------------------

8. the address specified in the mail from command is called envelope from address. it does not need to be the same as the sender's own address.
Rcpt to is equivalent to the following: the specified receiver address is called envelope to address, but it has nothing TO do with the actual to: What is the row.
9. why is there no rcpt cc or rcpt bcc :?
All receiver negotiation is implemented through the rcpt to command. if it is BCC, the recipient of the envelope is deleted after the negotiation is sent and received by the recipient.
10. emails are divided into envelope, header, and body.
Envelope from, envelope to and message from:, message to: are completely irrelevant.
Evnelope is provided by the SMTP backend between server hosts, while message from/to is provided by users. It is also different if there is a colon.

11. how can I check whether a letter is forged in the envelope part?
A. correlated Ed rows are correlated.
In the current SMTP mail transmission system, apart from the internal hosts at both ends of the envelope, consider the two company firewalls.
If the two firewall machines are A and B respectively, but the receiver checks the envelope written Ed: when the line is found to have passed C. it is forged.
B. received: whether the host and IP address pairs in the row correspond:
Receibed: from galangal.org (turmeric.com [104.128.23.115] by mail .bieberdorf.edu ....
C. manually added to the final stored row:
Received: from galangal.org ([104.128.23.115]) by mail .bieberdorf.edu (8.8.8.5)
Received: from lemongrass.org by galangal.org (8.7.3)
Received: from graprao.com by lemongrass.org (8.6.4)


Jephe Wu

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.