How to make a mailer not repeat itself
===

So I have managed to create some interesting behavoir that I have no idea how to debug. I have a mailer backed by a model and table. When the user creates a message a method generates an array of contacts to send the email to. We'll pick up there since that has been tested in console.

The model simply itterates through an array of recipients...

    class ContactMessage < ActiveRecord::Base
      ...
      def send_message(user)
      	self.recipients.each do |rec|
      	  unless rec.include?("@")
            contact = Contact.find(rec)
            to = "\"#{contact.first_name} #{contact.last_name}\" <#{contact.email}>"
          else
            to = rec
            contact = user.contact.new('email' => rec)
          end
         ContactMail.direct_mail(user, self, to, contact).deliver
        end
      end
    
    end

It should then make n number of new calls to the ContactMail.direct_mail method.

    class ContactMail < ActionMailer::Base
      helper :mail
      def direct_mail(user, contact_message, to, contact)
      	@user = user
      	@contact = contact
      	@contact_message = contact_message
      	@theme = @contact_message.theme
      	mail(:to => to, :subject => contact_message.subject, :from => "no-reply" << @user.website.domain, :reply_to => @user.email)
      end
      
      ...
    end

the mail() method renders the view using the @instance variables provided.

    <%= @user.website.title %>
    <%= @user.website.motto %> 
    ============================================================
    <%= @contact_message.message.html_safe.gsub(/<\/?[^><]*>/i, "") %>
    ============================================================
    This message is from <%= @user.first_name << " " << @user.last_name << " of " << @user.business%>
    Please reply to <%= @user.email %>
    <%= @user.telephone %>
    <%= @user.address_l1%>
    <%= @user.address_l2 unless @user.address_l2.blank?%>
    <%= @user.city << ", " << @user.state << " " << @user.zip %>
    <%= @user.website.domain %>


All is well and good, I am using MailCatcher to recieve all of the emails and terminal says they were sent.

However, each mail sent after the first the << @instance just keeps piling up onto eachother! It produceses something like

    Healthy Living
    Where massage makes health. 
    ============================================================
    asdfasdfasdfasd
    ============================================================
    This message is from Adam Fluke of Healthy Living LLC Fluke of Healthy Living LLC Fluke of Healthy Living LLC Fluke of Healthy Living LLC Fluke of Healthy Living LLC Fluke of Healthy Living LLC Fluke of Healthy Living LLC Fluke of Healthy Living LLC Fluke of Healthy Living LLC Fluke of Healthy Living LLC
    Please reply to fluke.a@gmail.com
    504-638-2222
    1822 Moss St
    Apt E
    New Orleans, AL 70119, AL 70119, AL 70119, AL 70119, AL 70119, AL 70119, AL 70119, AL 70119, AL 70119, AL 70119, AL 70119, AL 70119, AL 70119, AL 70119, AL 70119, AL 70119, AL 70119, AL 70119, AL 70119, AL 70119
    healthyliving.org

(this would be the fifth message sent, it gets progressively worse with each email sent.)

This is what I don't understand, based on my understanding of Mail and method calls, each message sent should be their own unique object and should not be interacting with eachother at all. Yet, the clearly are. This happens with += and <<, in text and html. WTF?

Any thoughts or help appreciated.