Reputation: 21088
It has been asked million times probably but my case is different and I have tried every config option imaginable and tried in production mode as well. The email is rendered but it doesn't appear anywhere. I even bought $15 MockSMPT app to see the emails but nothing goes out it seems.
Here are the configs for MockSMTP:
config.action_mailer.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:address => "localhost",
:port => 1025,
:domain => "whatever.com"
}
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true
I have tried every delivery_method
, :test
, :file
, I am ripping my hair off, nothing helps:
Rendered contact_mailer/contact_email.html.erb (2.1ms)
And this is it.
Code for sending is trivial:
def contact_email(contact, house=nil)
@house=house if house
@contact=contact
mail(to: contact.email, subject: "#{contact.name} new inquiry")
end
Rails 3.2.8
contact_controller.rb
:
def create
@contact = Contact.new(params[:contact])
if @contact.valid?
@house=House.find_by_id(params[:house_id])
ContactMailer::contact_email @contact, @house
end
end
Upvotes: 0
Views: 669
Reputation: 7614
You should write:
ContactMailer.contact_email(@contact, @house).deliver
You can read ActionMailer documentation here:
http://api.rubyonrails.org/classes/ActionMailer/Base.html
Your statement just creates Mail::Message object, deliver actually sends the email.
Upvotes: 1