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.
Did you setup ActionMailer in config/environments/production.rb?
2006/10/11, jsmorris [email protected]:
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.
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 [email protected]:
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 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 17/10/2006, at 2:18 PM, jsmorris wrote:
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.
When you want to deliver email with ActionMailer, you have to prefix
your method with “deliver_”, e.g. ActionMailer#generic_mailer
(instance method) needs to be called with
ActionMailer::deliver_generic_mailer (class method)
the << CODE CODE stuff is a heredoc [1] used to define the
mailer method to use UNLESS it is already defined. Then the second
half of the method calls ActionMailer to deliver the email. I had it
working a few months ago, I’ll try to dig up the code and put the
setup on the wiki (if i can find some spare some time for radiant
)
Bodhi
[1] Here document - Wikipedia