ActionMailer Message-Id field

I am attempting to set my own value for the message-id header in
emails
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.

Looking at action mailer’s base.rb file, you can see that the
perform_delivery_smtp method calls the ready_to_send method, which
calls
add_message_id, which definitively sets the message_id property to the
result of TMail::new_message_id.

Has anyone figured out a way to use their own message ids without
modifying the action mailer code?

On Sat, Apr 5, 2008 at 4:10 PM, Nikita P. [email protected]
wrote:

I am attempting to set my own value for the message-id header in
emails
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.


Rick DeNatale

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

I want that all letters from my SMTP server will be with message-id,
given by server, but not by TMail. My SMTP server couldn’t force
change message-id if it was setted before.

2008/4/6, Rick DeNatale [email protected]:

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.

Unfortunately, ActionMailer does this as a forced default, 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.

Regards

Mikel L.
TMail Maintainer

On Sat, Apr 5, 2008 at 9:49 PM, Mikel L. [email protected]
wrote:

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/

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs