I've read a few questions and http://guides.rubyonrails.org/action_mailer_basics.html on how to send emails with Rails but can't seem to get it to work within the context of my current application.
I had an existing emailer.rb
with a couple of methods that were identical apart from the parameters they accepted were named differently so I copied their format:
def quotation_notification(q)
@recipients = q.recipient_email
@from = q.partner_name + "<#{q.partner_email}>"
@subject = "New Quotation from " + q.partner_name
@body[:q] = q
end
I then created a new view file in emailers
named quotation_notification.rhtml
which just contains text for the moment.
I am then calling the function from inside a different controller and sending hardcoded parameters for now:
q = QuotationEmail.new(:recipient_email => 'martin@domain.co.uk', :partner_name => 'Martin Carlin', :partner_email => 'martin@domain.co.uk')
# send email
Emailer.deliver_quotation_notification(q)
Then finally, I created a new model for QuotationEmail
class QuotationEmail
def initialize(recipient_email, partner_name, partner_email)
@recipient_email = recipient_email
@partner_name = partner_name
@partner_name = partner_email
end
end
The error I get is ArgumentError (wrong number of arguments (1 for 3))
Eventually I'll be sending more parameters and hopefully attaching a pdf aswell but just trying to figure out why this isn't working first.