Try modifying your environment.rb to include the following
===
...
Rails::Initializer.run do |config|
# Settings in config/environments/* take precedence over those
specified here.
# ...
##### start narayan
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "mail.mydomain.com",
:port => "26",
:domain => "mydomain.com",
:user_name => "[EMAIL PROTECTED]",
:password => "xxxx",
:authentication => :login
}
##### end narayan
===
Hope it works!
-Narayan
On Oct 23, 8:47 am, Victor Vlist <[EMAIL PROTECTED]>
wrote:
> Hello, I am trying to make a very basic "contact me" form on my website.
> I have tried the following
> tutorials:http://railsforum.com/viewtopic.php?id=15172http://railsforum.com/viewtopic.php?id=404http://forums.site5.com/showthread.php?t=18522http://www.buildingwebapps.com/podcasts/6798-adding-a-contact-form-an...http://digitalpardoe.co.uk/blog/show/56
>
> I found the last one to fit my needs the best. I need to have forms for
> a person's name, email address and message. Upon clicking a submit
> button, I want that information emailed to a hardcoded email address.
>
> My setup is as follows:
>
> /config/environment.rb:
> [code=]
> ... (at the end)
> ActionMailer::Base.delivery_method = :smtp
> ActionMailer::Base.server_settings = {
> :address => 'localhost', #was told by hostgator that these
> are the correct settings
> :port => 25,
> :authentication => :login, # Don't change this one.
> :user_name => "mailer_username",
> :password => "mailer_password"}
>
> ActionMailer::Base.perform_deliveries = true
> ActionMailer::Base.raise_delivery_errors = true
> ActionMailer::Base.default_charset = "utf-8"
> [/code]
> /app/models/emailer.rb:
> [code=]
> class Emailer < ActionMailer::Base
> def contact_email(email_params, sent_at = Time.now)
> # You only need to customize @recipients.
> @recipients = "[EMAIL PROTECTED]"
> @from = email_params[:name] + " <" + @email_params[:address] + ">"
> @subject = email_params[:subject]
> @sent_on = sent_at
> @body["email_body"] = email_params[:body]
> @body["email_name"] = email_params[:name]
> end
> end
> [/code]
> /app/controllers/emailer_controller.rb
> [code=]
> class EmailerController < ApplicationController
> def send_mail
> Emailer::deliver_contact_email(params[:email])
> end
> end[/code]
> /app/views/emailer/contact_email.rhtml (this is the formatting of the
> message sent)
> [code=]
> Name:
>
> <%= @email_name %>
>
> Message:
>
> <%= @email_body %>
> [/code]
> /app/views/emailer/contact_page.rhtml (this is the form from which the
> message is made)
> [code=]
> <% form_tag :action => "send_mail" do %>
> <table>
> <tr>
> <td><label for="email_name">Name:</label></td>
> <td><%= text_field "email", "name", :size => 30 %></td>
> </tr>
> <tr>
> <td><label for="email_address">Email Address:</label></td>
> <td><%= text_field "email", "address", :size => 30 %></td>
> </tr>
> <tr>
> <td><label for="email_subject">Subject:</label></td>
> <td><%= text_field "email", "subject", :size => 30 %></td>
> </tr>
> <tr>
> <td><label for="email_body">Body:</label></td>
> <td><%= text_area "email", "body", :rows => 8, :cols => 30
> %></td>
> </tr>
> </table>
>
> <input type="submit" value="Send Email" class="primary" />
> <% end %>
> [/code]
> /app/config/routes.rb:
> [code=]
> ...
> map.connect 'contactme', :controller => 'emailer', :action =>
> 'contact_page' #testing
> ...
> [/code]
> When I fill out the contact forms and send, nothing happens. The only
> error I was getting with script/server was a depreciation error with the
> view, but Duplex helped me fix that.
>
> I contacted hostgator to see if my settings in environment.rb were
> correct, and they said they were. So I'm thinking I wasn't supposed to
> put the "def send_mail..." in it's own separate controller? I'm really
> not sure because this looks right to me.
>
> Some other information: I'm using simplelog 2.0.2 as my blogging
> platform on rails 2.0.2 and I'm trying to add this contact form to it.
> Simplelog works wonderfully, but maybe its causing problems for the
> mailer. Another thing, when I change "Base.server_settings" to
> "Base.smtp_settings" in /config/environment.rb, rails fails to start. I
> thought "Base.smtp_settings" was the new, better way for that setting.
> Does anyone have any hints for me on how to get this mailer working?
> I've spent days trying to figure this out, please help.
>
> If you read all of that, thank you very much for your time :)
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---