港股即時

Economic Calendar

Monday, September 25, 2017

E-mail RFC821, RFC2821

RFC822

SMTP Procedure

  • Mail command
    • MAIL <SP> FROM:<reverse-path> <CRLF>
      •          This command tells the SMTP-receiver that a new mail transaction is starting and to reset all its state tables and buffers, including any recipients or mail data.  It gives the reverse-path which can be used to report errors.  If accepted, the receiver-SMTP returns a 250 OK reply.
      • The <reverse-path> can contain more than just a mailbox.  The <reverse-path> is a reverse source routing list of hosts and source mailbox.  The first host in the <reverse-path> should be the host sending this command.
  • RCPT command
    • RCPT <SP> TO:<forward-path> <CRLF>
      • This command gives a forward-path identifying one recipient. If accepted, the receiver-SMTP returns a 250 OK reply, and stores the forward-path.  If the recipient is unknown the receiver-SMTP returns a 550 Failure reply.  This second step of  the procedure can be repeated any number of times.
      • The <forward-path> can contain more than just a mailbox.  The <forward-path> is a source routing list of hosts and the destination mailbox.  The first host in the <forward-path> should be the host receiving this command.
      • (Forwarding) some cases where the destination information in the  <forward-path> is incorrect, but the receiver-SMTP knows the correct destination.  In such cases, one of the following replies should be used to allow the sender to contact the correct destination. 
        • 251 User not local; will forward to <forward-path>
        • 551 User not local; please try <forward-path>
      • VERIFYING AND EXPANDING
        • VRFY command, the string is a user name, and the response may include the full name of the user and must include the mailbox of the user.
          • E.G
            • S: VRFY Smith
            • R: 250 Fred Smith <Smith@USC-ISIF.ARPA>
            • S: VRFY Smith
            • R: 251 User not local; will forward to <Smith@USCISIQ.ARPA>
            • S: VRFY Jones
            • R: 550 String does not match anything.
            • S: VRFY Jones
            • R: 551 User not local; please try <Jones@USC-ISIQ.ARPA>
            • S: VRFY Gourzenkyinplatz
            • R: 553 User ambiguous.
        • EXPN command, the string identifies a mailing list, and the multiline response may include the full name of the users and must give the mailboxes on the mailing list.
          • E.G.
            • S: EXPN Example-People
            • R: 250-Jon Postel <Postel@USC-ISIF.ARPA>
            • R: 250-Fred Fonebone <Fonebone@USC-ISIQ.ARPA>
            • R: 250-Sam Q. Smith <SQSmith@USC-ISIQ.ARPA>
            • R: 250-Quincy Smith <@USC-ISIF.ARPA:Q-Smith@ISI-VAXA.ARPA>
            • R: 250-<joe@foo-unix.ARPA>
            • R: 250 <xyz@bar-unix.ARPA>
            • S: EXPN Executive-Washroom-List
            • R: 550 Access Denied to You.
  • Data command
    • DATA <CRLF>
      • If accepted, the receiver-SMTP returns a 354 Intermediate reply and considers all succeeding lines to be the message text. When the end of text is received and stored the SMTP-receiver sends a 250 OK reply.
      • Since the mail data is sent on the transmission channel the end of the mail data must be indicated so that the command and reply dialog can be resumed.  SMTP indicates the end of the mail data by sending a line containing only a period.  A transparency procedure is used to prevent this from interfering with the user's text.
      • Mail data includes the memo header items such as Date, Subject, To, Cc, From.
      • SENDING AND MAILING
        • The main purpose of SMTP is to deliver messages to user's mailboxes.  A very similar service provided by some hosts is to deliver messages to user's terminals (provided the user is active on the host).  The delivery to the user's mailbox is called "mailing", the delivery to the user's terminal is called "sending".  Because in many hosts the implementation of sending is nearly identical to the implementation of mailing these two functions are combined in SMTP.
        • The following three command are defined to support the sending options.
          • SEND <SP> FROM:<reverse-path> <CRLF>
            • The SEND command requires that the mail data be delivered to the user's terminal.  If the user is not active (or not accepting terminal messages) on the host a 450 reply may returned to a RCPT command.  The mail transaction is successful if the message is delivered the terminal.
          • SOML <SP> FROM:<reverse-path> <CRLF>
            • The Send Or MaiL command requires that the mail data be delivered to the user's terminal if the user is active (and accepting terminal messages) on the host.  If the user is not active (or not accepting terminal messages) then the mail data is entered into the user's mailbox.  The mail transaction is successful if the message is delivered either to the terminal or the mailbox.
      • OPENING AND CLOSING
        • At the time the transmission channel is opened there is an exchange to ensure that the hosts are communicating with the hosts they think they are.
          • Opening
            • HELO <SP> <domain> <CRLF>
            • E.G.
              • R: 220 BBN-UNIX.ARPA Simple Mail Transfer Service Ready
              • S: HELO USC-ISIF.ARPA
              • R: 250 BBN-UNIX.ARPA
          • Closeing
            • QUIT <CRLF>
            • E.G.
              • S: QUIT
              • R: 221 BBN-UNIX.ARPA Service closing transmission channel
      • RELAYING
        • The forward-path may be a source route of the form"@ONE,@TWO:JOE@THREE", where ONE, TWO, and THREE are hosts.  This form is used to emphasize the distinction between an address and a route.  The mailbox is an absolute address, and the route is information about how to get there.  The two concepts should not be confused.



電子郵件的結構

  • 如傳統郵一樣,由「信封」和「信件」組成,但整個郵件是一個純文本檔案。純文件檔案按照RFC822標準框架組成,只要按此框架組成純文件檔案,就成為標準郵件。
  • RFC822:
    • 純文件檔案頭幾行是「信封」,然後一個空行後便是「信件」。
    • RFC822 規定字符必須為ASCII
    • 信封的正式名稱為 Header 。
    • Header由幾個部份 (header field) 組成
      • field-name: [field-body] CRLF
        • field name 是段名,RFC822定義了一部份段名及其語義,應用程序可自定義新段名,但不得與已有段名重覆。
        • field body 是段體, 與段名用 冒號分隔。
          • E.g.
          • From: Derek Wai <Group @ Hosta>
          • Sender: Haze@Hostb
          •  Reply-To:Hazze@Hostb
          • From, Sender, Reply-To 是 field name, 後面是field body
        • CRLF : 每個field 理論上是一行,若多於一行,則新一行要有一 space 或 tab 來代表是上一行的延續,稱Carriage-Return Line-Feed。
          • E.g.
          • Received: from m15-40.126.com (220.181.15.40)CRLF by localhost with SMTP;
          • Received: from m15-40.126.com (220.181.15.40)
          •  by localhost with SMTP;
    • 頭段功能
      1. 源地址
        •     From: mailbox   //  mail box 可以 username@domain, 或 user < user@doman>//
        •     Sender: mailbox  //若信件並非由寫信人的地址發出,則必須用sender再加上from。 即 sender:  1@abc.com  from 2@abc.com //
        •     Return-path: < [route] local-part@domain >  //由最後的轉發站回送郵件給發信人的路由。可選項route 指出路由,形式為domain_1, @domain_2, ... ..., @domian_n//
        •     Reply-To: mailbox
        •     Received[from domain][by domain][via atom][with atom]
          • [id msg-id][for local-part@domain]
          • ; date-time

http://003317.blog.51cto.com/2005292/611104

No comments:

Post a Comment