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
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?