Sign In
Start Page | Recent Changes | All Pages | Orphan Pages | Junebug Help

Comparing version 17 and version 16

TheI Mailerhave Extensionjust installed radiant in my dreamhost setup, and I also saw that this page was empty. So this is responsiblethe forbest anmoment enormousto amountwrite all the steps down while my memory is still fresh! This document is mostly a compendium of trafficseveral onsources, I will try to cite them when possible.

Having Radiant installed in Dreamhost requires to follow several steps, covering activation of FastCGI support, custom installation of gems, creating the MySQL databases, setting up the environment, and certain customizations. I now will describe them in detail.

h2. Enabling FastCGI

Go to your Dreamhost Control Panel, in Domains → Manage Domains, select the domain that is going to host the Radiant mailing list. People ask questions from installation toand usage, 
fromclick noton being“Edit” ablein tothe configureWebHosting itcolumn. properlyChoose toit, notand beingthen ablemake tosure send'FastCGI e-mails.

The source of all evilSuppor' is the lack of documentation of the Mailer Extension, being the README and the topics on the mailing list the only ones available. 
But, searching the mailing list and reading all the topics related to the Mailer Extension to find the answersenabled.

If you want cana bestep veryby tiresome 
(believestep me,with I'vescreenshots, done this). So, I thought I could helpvisit the communityentry andmade putby togetherWilliam thein mostRailsHosting, common"Deploying informationa aboutRails theApp Mailerwith Extension.DreamHost":http://www.railshosting.org/#dreamhost.

h2. Custom Installation of gems

The way to get the Mailer Extension is by subversion. So, from the Radiant root directory do as follows:

 cd vendor/extensions
 sudo svn co http://dev.radiantcms.org/svn/radiant/branches/mental/extensions/mailer
(The rake db:migrate:extensions command is not necessaryincluded forin the Mailerstandard extensioninstallation becauseon it doesn't have anything to add to the database.) The Mailer Extension is installed, now it's time to make it work. h2. Configuration The Mailer Extension is built upon the "ActionMailer framework":http://wiki.rubyonrails.org/rails/pages/ActionMailer,Dreamhost, so we need to configureadd the required gems. For this, you have to setup a custom gems repository in your local directory. The instructions are listed in the Dreamhost Wiki, in this "link":http://wiki.dreamhost.com/RubyGems. I will summarize them here to make it more comfortable for all. 1. Log in into a shell, for the user who is hosting the domain where you want to set Radiant. 2. Create the '.gems' directory, setup the environment variables, and load the new setup. To do this, add the following lines to 'bash_profile', and then update the enviroment running source .bash_profile

export GEM_HOME="$HOME/.gems" 
export GEM_PATH="$GEM_HOME:/usr/lib/ruby/gems/1.8" 
export PATH="$HOME/.gems/bin:$PATH" 
3. Edit or create the '.gemrc' file, and add the following (replace username appropiately)

gemhome: /home/yourname/.gems
gempath:
- /home/yourname/.gems
- /usr/lib/ruby/gems/1.8
h2. Creating the Database Radiant will need one database, and I will show here how to create a MySQL database to use it. Thiswith Radiant. Go to the Dreamhost Control Panel, under Goodies → Manage MySQL. Follow the on-screen instructions to create a new database. Note that you need a separate hostname (you can create one in the same page). Take note of the hostname, database name, username and password, as they will be doneneeded in the Radiant configuration. h2. Install and Setup Radiant So we are finally here! Go to the Shell window, and follow the standard Radiant installation instructions. Of course, always refer to the latest installation instructions in Installation. Note that path/to/project is not neccessarily the actual web path (actually, that is not recommended). I suggest you create something like 'radiantcms' in you home directory.

% gem install --include-dependencies radiant
% radiant --database mysql path/to/project
Then, configure the database. Modify the config/database.yml to point to your MySQL database, using the parameters you copied earlier. Set it as the *production* database. Finally, initialize Radiant:

% rake production db:bootstrap
h2. Modifications needed for Dreamhost In order for everything to work properly, you need to change some directory permissions, modify some scripts, and finally make a link to make your Radiant installation available to the public. Go to
and ensure the public directory is public. Type:

chmod -R 755 public
Check the public/.htaccess file, if it is set up properly. Modify the appropiate RewriteRule line to point to dispatch.fcgi instead of dispatch.cgi. It should look like this:

RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
Apparently, the environment variables we just setup get overwritten somewhere in the processing flow, so we have to force them. Modify the public/dispatch.fcgi file, and add the following before the 'require' lines (don't forget to adjust the username):

ENV['RAILS_ENV'] = 'production'
ENV["GEM_HOME"]="/home/username/.gems" 
ENV["GEM_PATH"]="/usr/lib/ruby/gems/1.8:/home/username/.gems" 
Ensure the selected environment is production in the config/environment.rb filefile. Uncomment the line:

ENV['RAILS_ENV'] ||= 'production'
Finally, create a link in theyour host to point to your radiant installation (modify according to your setup):
config/environments/
% ln -s ~/radiantcms/public ~/hostname/radiant
or directory.if Iyou prefer doingto sohave init as a subdomain:

% ln -s ~/radiantcms/public ~/subdomain.hostname
h2. That's it, Enjoy! Check the config/environment.rbReferences file,for so Imore can use it from production, test or development environments. Edit the config/environmemt.rbinformation and find the line that reads

 # Skip frameworks you're not going to use
 config.frameworks -= [ :action_web_service, :action_mailer ]  
remove
:action_mailer
from the list

 # Skip frameworks you're not going to use
 config.frameworks -= [ :action_web_service ]
Now, add the following configuration parameters (I put it at the end of the file, just before the line that reads require "status"):

 # Configure ActionMailer for Mailerspecial extension
 ActionMailer::Base.smtp_settingscases.

h2. = {
   :address => "your.smtp.server",
   :port => 25,
   :domain => "your.domain"
}
References the code above is based on my own configuration. For"Deploying a completeRails listApp ofwith parametersDreamHost":http://www.railshosting.org/#dreamhost "Dreamhost haveWiki, aRubyGems":http://wiki.dreamhost.com/RubyGems "Dreamhost lookWiki, at the "ActionMailer::Base Configuration Options"!http://api.rubyonrails.org/classes/ActionMailer/Base.html. That would be enough to make the Mailer Extension work, but after configuring the ActionMailer::Base as above, for some strange reason, it was still not sending e-mails. Everything was fine, the Mailer Extension was working, no errors, but no e-mails. So I thought I could figure out what was happening adding another line of configuration to the ActionMailer::Base on the config/environment.rb file

 ActionMailer::Base.raise_delivery_errors = true
After I put down this line, e-mails started to be sent (I really don't know why, any clue?), but as it has made the Mailer Extension work I'll keep it. Now, restart your server and let's create our mailer form. h2. Using Mailer # Create a new page; # On the page created, select "Mailer" from the page type dropdown list; # Create two new page parts "config" and "email" (you may use "email_html" instead, in order to send hml e-mails). h3. The "config" page part The "config" page part is where the Mailer configuration parameters are set, for example:

 mailers:
   contact:
     subject: my subject
     from: myemail@mydomain
     redirect_to: /where/you/want/visitors/to/go/after/sending/the/email
     recipients: 
       - recipient#1@domain
       - recipient#2@domain
On the second line, contact is actually the name of your Mailer form (more to come), whatever you name your Mailer form, substitute contact by it. This is because you can have many Mailer forms on the same page, so the Mailer Extension needs to know which one you're talking about. The next lines are self explanatory, I think :) *Warning*: config is a YAML formated file, so *INDENTATION MATTERS*! h3. The body page part The boby page part is where we code our Mailer form. The example below is based on a test form I was doing:

 
     Name:

E-mail:

Subject:

Message:

As you can see, there is a subject field. The text entered on this field will replace the one on the config part. I'll let other experimentations to you ;) The tags available for building the form are listed on the Mailer Extension [http://dev.radiantcms.org/svn/radiant/branches/mental/extensions/mailer/README README]. h3. The "email" page part The "email" page part is where we build our e-mail template. For example, based on the previous Mailer form, we could have an e-mail template like this:

 Name: 
 E-mail: 
 Subject: 
 Message: 
The is used the get the values entered by the user on the Mailer form. h2. The End This is not an extensive tutorial about using the Mailer Extension, but I think it covers the basics. I hope this may help someone in anyway.RubyOnRails":http://wiki.dreamhost.com/Ruby_on_Rails

Back to Page