Search code examples
ruby-on-railsemailimap

How do I pass additional information to into ActionMailer to handle incoming messages?


I have an application that checks multiple email accounts (think Webmail). Because I'm retrieving multiple accounts, I need to associate the inbound email with a user's account. However, I can't seem to find a way to do this.

If i pass into Fetcher a user_id in the options hash, from what I understand it creates it as an attribute. But, I'm unclear how to get the fetched message modified in such a way as to make it happy for ActionMailer. If I add an argument to the "receive" method, that fails with a message "wrong number of arguments."

If I try to modify the message retrieved, I get an error with "wrong number of arguments". And, because ActionMailer is not really a full class, I can't simply initialize it with the right data.

Any thoughts on how to pass this information?


Solution

  • I'll answer this because I hate not finding answers.

    I wrapped ActionMailer in another class. This new class took the additional attributes and handled them. This is how I got around this problem.