PDA

View Full Version : Help with RAILS email



davidkess
12-07-2007, 11:45 AM
I have a RAILS app that I built and loaded on my website. I would like to have a email form on the contact page so that people can email me directly. I created an ActiveMailer class and all that. I think my error is in the environment.rb config. Here is what I got


ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:address => "mail.mydomainname.com",
:port => 26,
:domain => "mydomainname.com",
:authentication => :login,
:user_name => "david@mydomainname.com",
:password => "mypassword"
}

In my model I have (my_mailer.rb)


class My_mailer < ActionMailer::Base
def send_question(subject1, body1, email_address, sent_at)
subject subject1
body :body1 => body1
recipients 'myemailaddress.com'
from email_address
sent_on sent_at
headers {}
end
end

In my controller I have (my_mailer_controller.rb)


class MyMailerController < ApplicationController
def send_email
subject = params[:email][:subject]
body = params[:email][:body]
email_address = params[:email][:email_address]
sent_at = Time.now
email = My_mailer.deliver_send_question(subject, body, email_address, sent_at)
end
end

I have the body in send_question.rhtml in the view for my_mailer

The form sends the information to the send_email action and that should call the send_question class and deliver the email. At least that is my limited understanding of it.

Any help would be great.