tags:

views:

23

answers:

1

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 @example 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.

+1  A: 

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)

aldrinleal
I know about all the MX stuff, my question is how "smart host" know what to do with the message ? Is there any default configuration ?
Vitaly Polonetsky
Yes, there is. Check the settings from postfix, which lists 4 kinds of mail hub profiles: http://www.postfix.org/STANDARD_CONFIGURATION_README.htmlIn general terms, it keeps a list of domains it should receive email, both for local delivery as well as for queueing for final delivery, or simply smart relay. It could also be managed via a SQL backend.Anyway, I remember something: Delivery Rules are evil. Postfix tries it best to streamline that, but if you take sendmail.cf sample, you will see a malevolent script in GNU m4 made just to handle this routing.
aldrinleal
The answer I was looking for is hidden in the second sentence of the original answer: SMTP server will not read the To: Cc: or Bcc: headers of the message. SMTP client will provide the addresses for which the SMTP server should receive the messages in "RCPT" TO lines.
Vitaly Polonetsky
Or the first paragraph. Truth is: The Mail Server never reads the envelope - it just appends the delivery route to it.
aldrinleal