Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the function of From and To at the DATA section of smtp mail?

Tags:

smtp

I am trying to understand using smtp to send mail. I saw an example and it is like this:

 HELO yourhost.yourdomain.edu
 MAIL FROM: <[email protected]>
 RCPT TO: <[email protected]>
 RCPT TO: <[email protected]>
 DATA
 Date: Sun, 30 Nov 98 nn:nn:nn EST
 From: Carol <[email protected]>
 To:   <[email protected]>
 Cc:   <[email protected]>
 Subject: Update

 Mike: Cindy stubbed her toe.  Bobby went to
    baseball camp.  Marsha made the cheerleading team.
    Jan got glasses.  Peter has an identity crisis.
    Greg made dates with 3 girls and couldn't
    remember their names.
 .
 QUIT

What i am confused about is, we already have MAIL FROM and RCPT TO at the beginning, why do we also have From:, To: and Cc: again at the DATA part? What is the difference between RCPT TO: at the header and To: at the DATA section? And if we assume we sent mail succesfully with these commands, what will be the output? I mean what is it that the receiver sees?

Thanks

like image 970
yrazlik Avatar asked Sep 18 '25 07:09

yrazlik


1 Answers

The body of the message is transmitted in the DATA section of the protocol.

However, SMTP uses the MAIL FROM and RCPT TO to record the envelope information (that may be different to the actual message). This is most apparent in mailing list delivery where the envelope is addressed to the actual recipient, while the body of the message often only contains a distribution list name.

The recipient will only be able to see the content in the DATA. The envelope is lost when the MTA (message transfer agent) places the content into the mail store for the MUA (message user agent) to retrieve and display to the user.

This has produced years of problems (and endless spam) due to the possibility of mismatched values, but was seen as the most appropriate mechanism when the RFC-822 structure and SMTP transport protocol and their successors were prepared.

The actual transport does not require that the message is formatted in any particular form. This is something that is validated by the receiving system to ensure that only well-formed mail is accepted for local delivery.

like image 101
Pekka Avatar answered Sep 21 '25 05:09

Pekka