Reputation: 11952
I'm sending an email to the following recipients:
[email protected]
, [email protected]
, [email protected]
The message is sent to my local smtp server that has to relay it to @example.com
and @test.com
.
My question is: how the server should do it ?
Leave the message as is and relay it to a more sophisticated smtp server that will do one of the other options
Break it into two messages and relay one message to @exampl
e and two others to @test.com
in one message
Break it into three messages and relay once to @example.com
and twice to @test.com
And how the receiving server, for example @example.com
know it should not send the @test.com
message by himself too? (any mail header?)
What if @example.com
and @test.com
are served by the same server, will it receive the message more than once?
I'm probably missing something in the SMTP protocol.
Upvotes: 5
Views: 12162
Reputation: 3609
The envelope (RFC822 and further) are just the outside bounds. The fun happens within the ESMTP protocol.
In terms of plain SMTP, each recipient (RCPT TO) fires up a new message in the outbox queue - One for each recipient. Then, it is delivered.
Now lets talk about the delivery: Supposed I asked to deliver to [email protected]. Here is how it works:
The host.com address is queried on DNS, in particular, for a record of MX (Mail Exchanger) type. (nslookup -q=MX should show you how it is done)
They are sorted (lowest number first), and delivery is tried on a round-robin basis using this sort.
When it is delivered to the any MX record host, its done. However, the reason there are multiple MX hosts is due to the need to queue up mail while on outages, for instance. So, a higher MX host is likely to just queue and not let the originating host server bounce and expire the message (and that is what happens when the message gets stuck on a given host - You can trace it via its Headers)
Each server has its own rules for delivery, however, when you forward to a host which tried to deliver itself on the MX target, we call that a Smart Host. A host knows whether or not it should queue for another host (relaying) or deliver locally via the SMTP greeting (HELO ).
Also: A single SMTP connection will let you send multiple messages, so even if you have to recipients, there is going to happen only one connection (although two messages in the mail queue)
Upvotes: 4