0

I have added a contact form to my site and am having a problem, when the message is sent I get my flash message, "successfully sent", however the email never arrives in my inbox. I am in development mode at the moment and my app/config file looks like this

 class Application < Rails::Application ActionMailer::Base.delivery_method = :smtp ActionMailer::Base.perform_deliveries = true ActionMailer::Base.raise_delivery_errors = true config.action_mailer.smtp_settings = { :address => "smtp.gmail.com", :port => 587, :domain => "gmail.com", :user_name => "[email protected]", :password => "example", :authentication => :plain, :enable_starttls_auto => true } config.action_mailer.default_url_options = { :host => "gmail.com" } 

My contact Controller is like this

 def new @message = Message.new end def create @message = Message.new(params[:message]) if @message.valid? NotificationsMailer.new_message(@message).deliver redirect_to(root_path, :notice => "Message was successfully sent.") else flash.now.alert = "Please fill all fields." render :new end end end 

and finally my Notification Mailer

 class NotificationsMailer < ActionMailer::Base default :from => "[email protected]" default :to => "[email protected]" def new_message(message) @message = message if message.file attachment_name = message.file.original_filename attachments[attachment_name] = message.file.read end mail(:subject => "[[email protected]] #{message.subject}") end end 

Am I missing anything obvious here as I have implemented this in another site which worked fine, just cant figure out what is going on

Any help appreciated

2
  • Have you analysed log? Search for something like Sent mail to [RECEIVER'S EMAIL] to check if mails was sent successfully. If you find similar log then check if your spam folder contains the mail? Commented Jul 20, 2012 at 12:47
  • I know this is an old question and you've likely moved on, but I'd first verify that you can successfully send the email using the console. Instantiate and deliver the email there. Commented Mar 24, 2015 at 14:46

1 Answer 1

1

I know you set it in your app/config.rb, but I would ensure config.action_mailer.perform_deliveries isn't being overridden in your config/environments/development.rb

Sign up to request clarification or add additional context in comments.

1 Comment

thanks for your answer, theres nothing in my config/environments/development that would override, still not working

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.