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

Comparing version 15 and version 14

IThe haveMailer justExtension installedis radiantresponsible infor myan dreamhostenormous setup,amount andof Itraffic alsoon sawthe thatRadiant thismailing pagelist. wasPeople empty.ask Soquestions thisfrom installation to usage, 
from not being able to configure it properly to not being able to send e-mails.

The source of all evil is the bestlack momentof todocumentation writeof 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 stepstopics downrelated whileto mythe memoryMailer Extension to find the answers you want can be very tiresome 
(believe me, I've done this). So, I thought I could help the community and put together the most common information about the Mailer Extension.

h2. Installation

The way to get the Mailer Extension is stillby fresh!subversion. ThisSo, document is mostly a compendium of several sources, 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 hostfrom the Radiant installationroot anddirectory clickdo onas "Edit"follows:

 cd invendor/extensions
 sudo thesvn WebHostingco column.http://dev.radiantcms.org/svn/radiant/branches/mental/extensions/mailer
(The Chooserake it,db:migrate:extensions and then make sure 'FastCGI Support' is enabled. If you want a step by step with screenshots, visit the entry made by William in RailsHosting, "Deploying a Rails App with DreamHost":http://www.railshosting.org/#dreamhost. h2. Custom Installation of gems Radiantcommand is not includednecessary infor the standardMailer installationextension onbecause Dreamhost,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, so we need to addconfigure the required gems. For this, you haveRadiant to setupuse ait. This customcan gemsbe repository in your local directory. The instructions are listeddone in the Dreamhostconfig/environment.rb Wiki,file in thisthe "link":http://wiki.dreamhost.com/RubyGems.config/environments/ directory. I willprefer summarizedoing themso herein the config/environment.rb file, so I can use it from production, test or development environments. Edit the config/environmemt.rb and find the line that reads

 # Skip frameworks you're not going to makeuse
 config.frameworks it-= more[ comfortable:action_web_service, for:action_mailer all.]  
1.remove Log
:action_mailer
in into a shell, forfrom the userlist

 # whoSkip isframeworks hostingyou're thenot domain where you wantgoing to setuse
 config.frameworks Radiant.-= [ :action_web_service ]
2. Create the '.gems' directory, setup the environment variables, and load the new setup. To do this,Now, add the following linesconfiguration toparameters '.bash_profile',(I andput thenit updateat the enviromentend runningof @sourcethe .bash_profile@file, just before the line that reads require "status"):

 # Configure ActionMailer for Mailer extension
 ActionMailer::Base.smtp_settings = {
   :address => "your.smtp.server",
   :port => 25,
   :domain => "your.domain"
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.the Creatingcode above is based on my own configuration. For a complete list of parameters have a look at the Database"ActionMailer::Base Configuration Options"!http://api.rubyonrails.org/classes/ActionMailer/Base.html. RadiantThat willwould needbe oneenough database,to andmake 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 willthought showI herecould howfigure toout createwhat awas MySQLhappening databaseadding toanother useline withof Radiant. Goconfiguration to the DreamhostActionMailer::Base Control Panel, under Goodies -> Manage MySQL. Followon the on-screenconfig/environment.rb instructionsfile

 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 database.page; # NoteOn thatthe 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 needname ayour separateMailer hostnameform, (yousubstitute contact by it. This is because you can createhave onemany inMailer forms on the same page).page, Take note ofso the hostname,Mailer databaseExtension name,needs usernameto andknow password,which asone theyyou're willtalking beabout. The needednext inlines theare Radiantself configuration.explanatory, I think :) h2.*Warning*: Installconfig andis Setupa RadiantYAML formated file, so *INDENTATION MATTERS*! Soh3. The body page part The boby page part is where we arecode finallyour here!Mailer Goform. toThe theexample Shell window, and follow the standard Radiant installation instructions. Of course, always refer to the latest installation instructions in "Installation":http://dev.radiantcms.org/radiant/wiki/Installation. Note that path/to/projectbelow is notbased neccessarilyon thea actualtest web path (actually, that is not recommended).form I suggestwas you create something like 'radiantcms' in you home directory.doing:

% gem install --include-dependencies radiant
% radiant --database mysql path/to/project
 
     Name:

E-mail:

Subject:

Message:

Then,As configureyou can see, there is a subject field. The text entered on this field will replace the database.one Modifyon the config/database.ymlconfig part. I'll let other experimentations to pointyou to;) The yourtags MySQLavailable database,for usingbuilding the parametersform youare copiedlisted earlier. Set it ason the **production**Mailer database.Extension [http://dev.radiantcms.org/svn/radiant/branches/mental/extensions/mailer/README README]. Finally,h3. initializeThe Radiant:

%"email" rakepage productionpart

The db:bootstrap
h2."email" Modificationspage neededpart foris Dreamhost Inwhere orderwe forbuild everythingour toe-mail worktemplate. properly,For youexample, needbased to change some directory permissions, modify some scripts, and finally make a link to make your Radiant installation available toon the public. Goprevious toMailer form, andwe ensurecould thehave publican directorye-mail 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 looktemplate like this:

 Name: 
 E-mail: 
 Subject: 
 Message: 
RewriteRule
The ^(.*)$ dispatch.fcgiis [QSA,L]
Apparently,used the environment variables we just setup get overwrittenthe somewherevalues 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 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@ file. Uncomment the line:

ENV['RAILS_ENV'] ||= 'production'
Finally, create a link in your host to point to your radiant installation (modify according to your setup):

% ln -s ~/radiantcms/public ~/hostname/radiant
or if you prefer to have it as a subdomain:

% ln -s ~/radiantcms/public ~/subdomain.hostname
h2. That's it, Enjoy! Check the References for more information and for special cases. h2. References "Deploying a Rails App with DreamHost":http://www.railshosting.org/#dreamhost "Dreamhost Wiki, RubyGems":http://wiki.dreamhost.com/RubyGems "Dreamhost Wiki, RubyOnRails":http://wiki.dreamhost.com/Ruby_on_Rails "Dreamhost Wiki, Talk on Ruby on Rails":http://wiki.dreamhost.com/Talk:Ruby_on_Rails anyway.

Back to Page