Friday, 7 November 2008

Rails 2.0 ActionMailer and SMTP email

Okay, you want to use ActionaMailer in Rails to send smtp mail. First some useful links:




1 - Create a new file in the config/initializers/action_mailer.rb (The file can be called anything)

2 - Place the following settings in it:



ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.default_charset = "utf-8"
ActionMailer::Base.raise_delivery_errors = true

ActionMailer::Base.smtp_settings = {
:address => "your.smtp.server",
:port => 25,
:domain => "your.domain",
:user_name => "username",
:password => "password"
}



You should be able to send SMTP mail. Go and read the above doc about using ActionMailer to create the email and send it.

No comments: