Customize from address on replies

Hi, we needed to change the from address on replies based on the from address of the original email. We have 100+ emails that people email us with and that drives a lot of how the email is responded to etc. We can create 100+ emails on the email settings, add 100+ groups to accomplish this, but its a bit hard. Groups have a default email that drives the from address since it can’t be driven by the ticket itself. Filters can drive emails into groups.

Currently this logic lives in adds_metadata_email.rb in app/models/ticket/article. For now I’ve just customized the code a bit.

def metadata_email_process_from
    #email_address = ticket.group.email_address
    self.from = ticket.articles.first.to
    #self.from = Channel::EmailBuild.recipient_line(recipient_name(email_address), email_address.email)
  end

This works pretty well although during upgrades i’ll have to patch it. Not sure if there is a standard way to say overload the .rb file more cleanly.

I’m just wondering if there is a better way to approach this. I could set a custom property on the mail if we had some way of doing a callback to some .rb file. Then refer to it here. If self.from could just equal a template string that might help, but it doesn’t seem like the concept of “to” lives at the ticket level, but really its the first article/email that drives it.

Please use the template, thank you.