views:

89

answers:

1

I'm working on an app that needs to be able to send out email updates and then route the reply back to the original item.

All emails will come to a single address (this can't change unfortunately), and I need to be able to determine where they go. My initial thought was setting the message-id for the item so that it comes back as a References header.

any ideas on how to accomplish this with ActionMailer?

A: 

FINALLY found it.

First the problem: ActionMailer calls on the ready_to_send function inside TMail when sending using smtp, which in-turn calls the add_message_id function which overrides anything you put there.

Solution: there's an undocumented (as far as I can tell) method in TMail called enforced_message_id=(val). using this INSTEAD of message_id ensures that add_message_id won't overwrite your values. For example, you could:

mail = MyMailer.create_mail_function(values)
mail.enforced_message_id = '<my_not_proper_message_id>'
MyMailer.deliver(mail)

You need to be careful with this, because message_id's can be tricky. They must be unique and valid. I assume there's a reason TMail made it a bit of a pain to override the default.

Hopefully this saves someone a wasted afternoon (speaking from experience here ;-)

Ryan