Forum: Ruby on Rails Action Mailer 3.2.9 returns duplicates in deliveries array

171ea139761951336b844e708d1547ab?d=identicon&s=25 James Byrne (byrnejb)
on 2012-12-05 22:22
I am extracting a standalone batch application from a Rails 3.0.1
project.  This requires only ActiveRecord and ActionMailer.  In my
testing I set

   ActionMailer::Base.delivery_method = :test

This causes the mail to be delivered to the
ActionMailer::Base.deliveries array.  However, I am getting two of the
test email messages placed in the deliveries array instead of just one.
For example:

'[
#<Mail::Message:38151600,
Multipart: false,
Headers:
<Date: Wed, 05 Dec 2012 16:05:16 -0500>,
<From: forex.control@harte-lyne.ca>,
<To: forex.test@harte-lyne.ca>,
<Message-ID:
<50bfb70ca7ea9_78aa14427fc856@xnet241.hamilton.harte-lyne.ca.mail>>,
<Subject: [ForEx] 2012-12-05 - Foreign Exchange Rates Central Bank
Update Notice>,
<Mime-Version: 1.0>,
<Content-Type: text/plain>,
<Content-Transfer-Encoding: 7bit>>,

#<Mail::Message:38151600,
Multipart: false,
Headers:
<Date: Wed, 05 Dec 2012 16:05:16 -0500>,
<From: forex.control@harte-lyne.ca>,
<To: forex.test@harte-lyne.ca>,
<Message-ID:
<50bfb70ca7ea9_78aa14427fc856@xnet241.hamilton.harte-lyne.ca.mail>>,
<Subject: [ForEx] 2012-12-05 - Foreign Exchange Rates Central Bank
Update Notice>,
<Mime-Version: 1.0>,
<Content-Type: text/plain>,
<Content-Transfer-Encoding: 7bit>>
]'

I can forcibly fix this with a call to deliveries.unique but I would
rather find out what is actually happening.  Wherever this is occuring
it is between the call to the mail method in the mailer class and the
return from that class back to the calling script.  As I provide no
intervening code and since self.deliveries does not exist inside the
mailer class on return from the mail method I gather that this array and
method is being created and populated somewhere in the ActionMailer
stack outside of my pervue.

Does anyone have any idea why this is happening?
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.