JDutil / contact_us

Gem providing simple Contact Form functionality with a Rails 3+ Engine.
http://contact-us-demo.herokuapp.com
MIT License
134 stars 57 forks source link

contact_us don`t send mail #11

Closed suely closed 12 years ago

suely commented 12 years ago

I installed formtastic following the instrucctions:

1) gem 'formtastic' 2) Run the installation generator: 3) rails generate formtastic:install 4) gem 'contact_us', '~> 0.1.4' 5) bundle 6) bundle exec rake contact_us:install 7) modify my config.mailer_to = "lopez.suely@gmail.com"

but doesn`t work! Im Using rails 3.1...

JDutil commented 12 years ago

Are your rails application mailer settings configured? Perhaps I should mention that in the installation instructions as well. Please check your development or production environment file to make sure you have setup the ActionMailer settings. You can read more about the configuration within the Rails guides as well if you have any trouble: http://guides.rubyonrails.org/action_mailer_basics.html#action-mailer-configuration

suely commented 12 years ago

my app/enviroments/development.rb is

Demoat::Application.configure do

Settings specified here will take precedence over those in config/application.rb

In the development environment your application's code is reloaded on

every request. This slows down response time but is perfect for development

since you don't have to restart the web server when you make code changes.

config.cache_classes = false

Log error messages when you accidentally call methods on nil.

config.whiny_nils = true

Show full error reports and disable caching

config.consider_all_requests_local = true config.action_controller.perform_caching = false

Don't care if the mailer can't send

config.action_mailer.raise_delivery_errors = true

yo he agregado este linea es para smtp mails

config.action_mailer.delivery_method = :smpt

Print deprecation notices to the Rails logger

config.active_support.deprecation = :log

Only use best-standards-support built into browsers

config.action_dispatch.best_standards_support = :builtin

Do not compress assets

config.assets.compress = false

Expands the lines which load the assets

config.assets.debug = true end

JDutil commented 12 years ago

Yea you will need to setup your applications mailer settings so that it knows how to send the emails. This is an issue with your application configuration and not ContactUs. Please refer to the guides link above for more detailed information. Or you may find any answers to your questions on Stackoverflow. Basically you will need to either setup sendmail or an smtp configuration to send any emails.

Personally I use MockSMTP app for testing development emails. Or you may try using Ryan Bates letter_opener instead for a free solution.

In production you will want to setup your ActionMailer configuration to use your hosting providers mailing solution, which is typically a SMTP relay.

suely commented 12 years ago

Ok, I configured, now send mail to the "admin" BUT doesn't send mail to the user, I would like something like "thanks for you inquiry..." but the user don't get it, besides I can`t add more fields like

<%= f.input :name, :label => t('.name') %>

because I get this: undefined method `name' for #ContactUs::Contact:0x2b2f5d0

or change the message field by adding:

<%= f.input :message, :as => :text, :rows 5 :label => t('.message') %> because I want just 5 rows, not a textarea that big... I get: SyntaxError in Contact_us/contacts#new I now that Im doing something wrong...or missing something, and you are a busy man but please can you help me with this issue?

JDutil commented 12 years ago

You will need to fork this repo and then point your Gemfile to your own fork of the project with the git option. Once you have your own fork of the repo setup you can make some of the modifications that you would like, such as, sending an email to the user and adding the name field. In order to add the name field you will need:

attr_accessor :name

added to the Contact model and a validator if desired. You would also then add to the Contact models save method the user email deliver call, and modify the mailer to have your user email method as well.

I don't plan to add those features to this library at least not at the moment as I intend to keep it as a bare minimum starting point for people to customize to their needs.

As for the rows on the message field I would recommend simply using CSS to style the form how you would like. Or you can double check how the formtastic syntax works, but I believe you would need to do:

<%= f.input :message, :as => :text, :label => t('.message'), :input_html => {:rows => 5} %>