ActionMailer Sends Multiple Messages


#1

When i use “MyMailer.deliver_reply()” in my console, I send an email
exactly as i would expect, but when i call “MyMailer.deliver_reply()”
inside of my receive method, my app sends multiple duplicate messages,
Do you have any clue what may be causing this behavior?

Here is a copy of my log file http://pastie.org/427306.

Here is some pseudo code of what my mailer looks like:

class MyMailer < ActionMailer::Base
def receive(email)
# code to store email information
MyMailer.deliver_reply(email_address_of_sendee)
end

def reply(to_email)
   # code to send email, works great when called through console
end

end

This mailer takes in an email stores it, and then thanks the sender for
sending something automatically


#2

So it’s been awhile since i posted this question. I’m not 100% on why
its sending multiple emails, i believe it may be interperting both the
plaintext and html version of the email, as seperate entities, or it may
be a bug in mailer fetcher daemon. Either way, i ended up writing the
incoming emails to a database, then checking to make sure we had a
unique to_email with scope: => [:body]. once i did that, and put an if
statement into my receive method, everything worked fine. If you have
any guesses why its seeing four messages when its only supposed to see
one, please let me know.