On Sat, Apr 5, 2008 at 9:49 PM, Mikel Lindsaar <raasdnil / gmail.com> wrote:
> >  >  delivered via ActionMailer.  The underlying TMail object allows the
>  >  >  message_id to be set, but it looks like the deliver method of action
>  >  >  mailer will overwrite any value that is presently there at the time of
>  >  >  delivery.
>  >  I'm wondering if there's a legitimate use case for this.  The one
>  >  reason I can think of for doing this is to forge an untraceable
>  >  message-id on a spam e-mail.
>
>  It is a good default action as you want every email to have a unique
>  message_id, in fact, you need to have a unique message id per the
>  RFCs.

If you are trying to follow the RFCs you need to ensuer that the
message-id is unique.  Normally this is done by letting the either the
MSA or the first MTA (acting as the MSA) which processes the message
assign it.

Having looked at the code, it appears that TMail can act as a sort of
MSA, and generate the message-id in preparation for sending the
message via SMTP.

>  Unfortunately, ActionMailer does this as a forced default,

ActionMailer doesn't send the add_message_id, this appears to be a
side-effect of the call to ActionMailer::Base#perform_delivery_smtp
which sends prepare_to_send to it's argument which is a TMail mail object.

ActionMailer::Base#perform_delivery_smtp is a private method which is
invoked by ActionMailer::Base#deliver! if the delivery method is
:smtp.

On the other hand, if the delivery method is :sendmail then the
encoded mail object is handed off to the local MTA without assigning a
message-id which lets, sendmail, postfix or whatever the local MTA is
assign it.

>> perhaps the
>  OP could submit a patch which simply says:
>
>   mail.add_message_id unless mail.message_id
>  That would then only add a message ID if the mail did not already have
>  one. That would probably work in most cases, but you would have to
>  look at the consequences of replying to messages etc and handle those,
>  you need to ensure that you know what message ids are unique and not.

It seems to me that first, this would be a TMail patch rather than an
ActionMailer patch, but also that it's probably inadvisable, better to
continue to let the MTA or the TMail implemented MSA code handle
message-id generation.

If the concern is properly implementing the RFCs and ensuring
uniqueness and traceability of message-ids, then TMail, postfix,
sendmail and their ilk are the proper responsible parties rather than
the code producing the contents of the emails.

-- 
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/