title: SMTP server correct email routing
body: <p>I'm trying to implement a SMTP server at the moment and I've question regarding the routing...
  Imagine, a client (foo@bar.com) sends a mail to foo1@bar1.com, foo2@bar2.com and foo3@bar3.com.
  What happens when the SMTP server sees the message? Now, I'm not sure if the following sequence is correct:</p>
  
  <ol>
  <li>The SMTP server will put the mail into the outbox of foo@bar.com</li>
  <li>For each recipient (except foo@bar.com) in the envelope, the SMTP server will do:
  
  <ol>
  <li>Retrieve the MX record</li>
  <li>Connect to the SMTP server determined by the MX record</li>
  <li>Send HELO/EHLO command</li>
  <li>Send MAIL FROM command (foo@bar.com)</li>
  <li>Send RCPT TO command (e.g. foo1@bar1.com)</li>
  <li>Send DATA command</li>
  <li>Send QUIT command</li>
  </ol></li>
  </ol>
  
  <p>Are these steps correct? For me it makes sense that the SMTP of the sender processes all the communication, but I've found some pages (e.g. <a href="https://www.msxfaq.de/internet/envelope.htm" rel="nofollow noreferrer">https://www.msxfaq.de/internet/envelope.htm</a>) where a mail server only forwards the message to the next SMTP server and each SMTP server removes one recipient from envelop's rcpt-to list, e.g.</p>
  
  <p><a href="https://i.stack.imgur.com/qnhA9.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qnhA9.gif" alt="enter image description here"></a></p>
  
  <p>So, what's correct...?</p>
  
  <ol>
  <li>Sender's SMTP handles all the routing</li>
  <li>Sender's SMTP removes one recipient (in this case foo@bar.com) and then forwards the message to the next SMTP server</li>
  </ol>