Guest User

Untitled

a guest
Jul 30th, 2018
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. Rails 3 - Action Mailer not sending message
  2. <%= button_to 'Buy', review_hvacs_path(:b => true, :h => hvac, :a => params[:a], :s => params[:s]) %>
  3.  
  4. @buy = params[:b]
  5. if !@buy.nil?
  6. @currentHvac = Hvac.find(params[:h])
  7. @supplier = HvacSupplier.find(@currentHvac.hvac_supplier_id)
  8. Notifier.gmail_message(@supplier)
  9. end
  10.  
  11. # Don't care if the mailer can't send
  12. config.action_mailer.raise_delivery_errors = false
  13.  
  14. config.action_mailer.delivery_method = :smtp
  15. config.action_mailer.smtp_settings = {
  16. :enable_smarttls_auto => true,
  17. :address => 'smtp.gmail.com',
  18. :port => 587,
  19. :authentication => :plain,
  20. :domain => 'gmail.com',
  21. :username => '<my email address>@gmail.com',
  22. :password => '<my password>'
  23. }
  24.  
  25. class Notifier < ActionMailer::Base
  26. default from: "user@address.com"
  27.  
  28. # Subject can be set in your I18n file at config/locales/en.yml
  29. # with the following lookup:
  30. #
  31. # en.notifier.gmail_message.subject
  32. #
  33. def gmail_message(supplier)
  34. @greeting = "HVAC Equipment Purchase"
  35. @supplier = supplier
  36.  
  37. mail(:to => supplier.email, :subject => "HVAC Equipment Enquiry")
  38. end
  39. end
  40.  
  41. Notifier#gmail_message
  42.  
  43. <%= @greeting %>, I am interesting in purchasing replacement equipment, and would like an evaluation.
Add Comment
Please, Sign In to add comment