Put this in the environment.rb file(I use the google smtp server so I
had to install the action_mailer_tls plugin):

  config.action_mailer.raise_delivery_errors = false
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.default_content_type = "text/html"
  config.action_mailer.default_url_options = { :host =>
"domainname.com" }
  config.action_mailer.smtp_settings = {
    :tls              => true,
    :address          => "smtp.gmail.com",
    :port             => 587,
    :domain           => "domainname.com",
    :authentication   => :plain,
    :user_name        => "username",
    :password         => "password"
  }


Here is a snip from new_question_message.html.erb I have:

Question from..: <%= @question.name %><br />
Email..........: <%= @question.email %><br />
<% if @question.phonenumber -%>
Phonenumber....: <%= @question.phonenumber %><br />
<% end -%>
Subject........: <%= @question.subject %><br />
=========================================<br />
<%= @question.description %><br />


Then when I send this I have to pass the object:

mail = CustomerMailer.create_new_question_message(@question)
CustomerMailer.deliver(mail)

customer_mailer is not a controller its a actionmailer and it lives in
the /app/models directory

When you use the ruby script/generate mailer customermailer command it
creates that for you.

So the steps would be:

- Create the mailer with generate mailer
- Add a mailer action like welcome_message
- Setup your environment.rb with the correct smtp setup
- add the deliver action to your action in your controller (Imprtant
is to use CustomerMailer.create_ <- )

That should be all you need.

If you don't want to wait for the email to be sent (Sometimes the app
waits a second or 3 to send an email which does not make for a snappy
interface) Watch this http://railscasts.com/episodes/128-starling-and-workling
Starling and Workling works great to offload the email delivery.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to