· 8 years ago · Jul 30, 2018, 10:50 AM
1Rails 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]
5if !@buy.nil?
6 @currentHvac = Hvac.find(params[:h])
7 @supplier = HvacSupplier.find(@currentHvac.hvac_supplier_id)
8 Notifier.gmail_message(@supplier)
9end
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
25class 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
39end
40
41Notifier#gmail_message
42
43<%= @greeting %>, I am interesting in purchasing replacement equipment, and would like an evaluation.