[Radiant] Mailer behavior...anybody have any more tips to get it working?

jsmorris jsmorris at gmail.com
Tue Oct 17 00:18:43 CDT 2006


Still working on trying to get the mailer behavior to work.  I tried
to configure the ActionMailer in both files, but no success.  I do,
however, now get an error message on my page after I try to send the
mail.  The error is

"Error encounter while trying to send email. undefined method
`deliver_generic_mailer' for ActionMailer::Base:Class"

So, I got my hands dirty and tried to debug the code provided in the
behavior.  It looks like in the send_mail() method, the author is
trying to dynamically add a method to the ActionMailer::Base class,
but I am still too new to ruby to understand this completely.

My confusion is why the error message is saying that the calling
method is deliver_generic_mailer, but the method that the author is
adding to the ActionMailer::Base is called generic_mailer.  I tried to
just call this method, but that didn't work.

After seeing the below code, does it look correct?  Can anyone
describe what the <<-CODE <snip> CODE syntax is all about?  Thanks for
any help in advance

Here is a snippet of the code

      ActionMailer::Base.module_eval( <<-CODE ) unless
ActionMailer::Base.respond_to? 'generic_mailer'
          def generic_mailer(options)
            @recipients = options[:recipients]
            @from = options[:from] || ""
            @cc = options[:cc] || ""
            @bcc = options[:bcc] || ""
            @subject = options[:subject] || ""
            @headers = options[:headers] || {}
            @charset = options[:charset] || "utf-8"
            if options.has_key? :html_body
              part "text/html" do |a|
                a.body = options[:html_body] || ""
              end
            end
            if options.has_key? :plain_body
              part "text/plain" do |p|
                p.body = options[:plain_body] || ""
              end
            end
          end
      CODE
      # Now deliver mail using our new generic_mail method
      ActionMailer::Base.deliver_generic_mailer(
        :recipients => recipients,
        :from => from,
        :subject => form_data[:subject] || "Form Mail from #{request.host}",
        :plain_body => plain_body,
        :html_body => html_body
      )

On 10/12/06, Giovanni Intini <intinig at gmail.com> wrote:
> Well I'm not sure really. Your reasoning is logical, I just followed the
> tutorial in the AWDWR book and it suggested to edit the production.rb file,
> and it worked :)
>
>
> 2006/10/11, jsmorris < jsmorris at gmail.com>:
> > I did set up ActionMailer in the config/environment.rb file, but not
> > in the environments/production.rb file.
> >
> > My understanding was that the config/environment.rb was for settings
> > in all environments and if you wanted different configuration per
> > environment, then you used the specific file
> > envrionment/production.rb.
> >
> > Am I wrong in this assumption?  But, I will move the ActionMailer
> > config to that file and see if I get a different result and post back
> > to the list.
> >
> > Thanks for the help.
> >
> >
> > On 10/10/06, Giovanni Intini <intinig at gmail.com> wrote:
> > > Did you setup ActionMailer in
> > > config/environments/production.rb?
> > >
> > > 2006/10/11, jsmorris < jsmorris at gmail.com>:
> > > >
> > > > I have scoured the list and it seems that several people are having
> > > > issues with the mailer behavior and I am one of them.
> > > >
> > > > I have tried all the suggestions that I found in the mailing list, but
> > > > still it doesn't work.
> > > >
> > > > I have edited my environment.rb file to remove the ActionMailer from
> > > > being excluded on startup.  I have add
> > > > ActionMailer::Base.server_settings needed for my hosting provider
> > > > (RailsPlayground).  I have configured my page, config and email parts.
> > > >
> > > > My form displays correctly, I click send, I don't see any errors on
> > > > screen or in the production log file but the email never shows up.
> > > >
> > > > Is there any more troubleshooting that I can do to make sure my
> > > > configuration is correct?  I guess the next step is to debug the
> > > > behavior, but since I am still a nuby, I find it difficult.  I was
> > > > hoping one of the smart people on this list would have an answer.
> > > >
> > > > Any help or guidance would be appreciated.
> > > > _______________________________________________
> > > > Radiant mailing list
> > > > Post:   Radiant at lists.radiantcms.org
> > > > Search: http://radiantcms.org/mailing-list/search/
> > > > Site:
> > > http://lists.radiantcms.org/mailman/listinfo/radiant
> > > >
> > >
> > >
> > > _______________________________________________
> > > Radiant mailing list
> > > Post:   Radiant at lists.radiantcms.org
> > > Search: http://radiantcms.org/mailing-list/search/
> > > Site:
> > > http://lists.radiantcms.org/mailman/listinfo/radiant
> > >
> > >
> > _______________________________________________
> > Radiant mailing list
> > Post:   Radiant at lists.radiantcms.org
> > Search: http://radiantcms.org/mailing-list/search/
> > Site:
> http://lists.radiantcms.org/mailman/listinfo/radiant
> >
>
>
> _______________________________________________
> Radiant mailing list
> Post:   Radiant at lists.radiantcms.org
> Search: http://radiantcms.org/mailing-list/search/
> Site:
> http://lists.radiantcms.org/mailman/listinfo/radiant
>
>



More information about the Radiant mailing list