# ActionMailer Sends Multiple Messages

**URL:** <https://www.ruby-forum.com/t/actionmailer-sends-multiple-messages/163913>\
**Category:** Rails\
**Created:** [March 26, 2009, 3:47am UTC](https://www.ruby-forum.com/t/actionmailer-sends-multiple-messages/163913 "2009-03-26T03:47:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![indigoi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/b3f665/32.png) [@indigoi](https://www.ruby-forum.com/u/indigoi)\
**Post date:** [March 26, 2009, 3:47am UTC](https://www.ruby-forum.com/t/actionmailer-sends-multiple-messages/163913/1 "2009-03-26T03:47:08Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![indigoi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/b3f665/32.png) [@indigoi](https://www.ruby-forum.com/u/indigoi)\
**Post date:** [June 26, 2009, 10:09pm UTC](https://www.ruby-forum.com/t/actionmailer-sends-multiple-messages/163913/2 "2009-06-26T22:09:20Z")

</div>

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.
