marked
marked

Reputation: 589

Rails 3 - Action Mailer not sending message

I have a button 'buy' which links to the 'review' page like so:

<%= button_to 'Buy', review_hvacs_path(:b => true, :h => hvac, :a => params[:a], :s => params[:s]) %>

This calls the review action in the controller, 'hvacs_controller' which contains..

@buy = params[:b]
if [email protected]?
  @currentHvac = Hvac.find(params[:h])
  @supplier = HvacSupplier.find(@currentHvac.hvac_supplier_id)
  Notifier.gmail_message(@supplier)
end

I am trying to send the message if the user presses the buy button.

My development environment looks like this:

  # Don't care if the mailer can't send
  config.action_mailer.raise_delivery_errors = false

  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
    :enable_smarttls_auto => true,
    :address => 'smtp.gmail.com',
    :port => 587,
    :authentication => :plain,
    :domain => 'gmail.com',
    :username => '<my email address>@gmail.com',
    :password => '<my password>'
  }

...and my mailer looks like this:

class Notifier < ActionMailer::Base
  default from: "[email protected]"

  # Subject can be set in your I18n file at config/locales/en.yml
  # with the following lookup:
  #
  #   en.notifier.gmail_message.subject
  #
  def gmail_message(supplier)
    @greeting = "HVAC Equipment Purchase"
    @supplier = supplier

    mail(:to => supplier.email, :subject => "HVAC Equipment Enquiry")
  end
end

Message:

Notifier#gmail_message

<%= @greeting %>, I am interesting in purchasing replacement equipment, and would like an evaluation.

Would anyone have any insight? I am missing something? If I left out any details, I will post them.

Upvotes: 0

Views: 296

Answers (1)

James
James

Reputation: 4807

Notifier.gmail_message(@supplier).deliver

Upvotes: 1

Related Questions