6

I have a need to do so, because it seems logical to me:

def notification(vehicle) 
   @vehicle = vehicle

   mail(:to => @vehicle.owner.email_address, :template_name => "n_o")
   mail(:to => @vehicle.booker.email_address, :template_name => "n_b")

end

The problem is: I'm receiving only the last e-mail. So, in my example above, only the booker would receive the email and nothing is being sent to the owner.

What is the problem ? How to solve it ? Should I create two separate mailing functions, like notification_owner(vehicle) and notification_booker(vehicle), or there is a simplier solution ?

Thanks!

Dmitri
  • 2,451
  • 6
  • 35
  • 55

2 Answers2

2

Ok. So, silly me, I forgot to mention that I'm dealing with delayed_jobs gem. So, the problem was, that I forgot to specify the ".deliver!" action after each "mail" function.

So, it should look like this:

mail(:to => @vehicle.owner.email_address, :template_name => "n_o").deliver!
mail(:to => @vehicle.booker.email_address, :template_name => "n_b").deliver!

But still. Thank you for your support!

Dmitri
  • 2,451
  • 6
  • 35
  • 55
0

Try:

def notification(vehicle,template_name) 
  @vehicle = vehicle
  mail(:to => @vehicle.owner.email_address, :template_name => template_name)
end


Mailer.notification(@vehicle,"n_o").deliver 
Mailer.notification(@vehicle,"n_b").deliver 
shweta
  • 8,019
  • 1
  • 40
  • 43