ActionMailer 3 does not generate a body from template

I am unable to generate a message body using ActionMailer 3.

This problem occurs even for ActionMailer classes and views that are
unchanged from Rails-2.3. When these files are run with Rails 2.3
emails with bodies result. When exactly the same files are used in a
Rails 3 project the headers are produced but no body.

I am at a loss to explain this. Initially I thought that maybe the API
had changed in such a fashion as to drop the old template naming
convention. However, having reworked these files to use the new api
exactly the same behaviour is observed, only headers are produced.

The new files are app/mailers/forex_mailer.rb and
app/views/forex_mailer/forex_cacb_update_notice.plain.erb

app/mailers/forex_mailer.rb contains this method

def forex_cacb_update_notice(
rates,
to_address = ‘[email protected]’,
fm_address = ‘[email protected]’ )

mail( :to => recipients, :from => fm_address, :subject => subject )

The call used to invoke this mailer is:

ForexMailer.forex_cacb_update_notice(rates, send_to).deliver

I therefore suspected that there must be something that has changed in
how the templates are parsed. So, taking a hint from the API Readme I
changed the name of the template files from x.plain.rb to
x.text.plain.rb. This had no effect.

As these templates are a mixture of fixed text and interpolated ruby
values I expected that I should see at least the fixed text portions of
the templates in the message body, but I am seeing nothing at all.
Inspection of the deliveries array shows this:

#<Mail::Message:23533088849320, Multipart: false, Headers: <Date: Mon,
25 Oct 2010 14:16:22 -0400>, <From: [email protected]>, <To:
[email protected]>, <Message-ID:
[email protected]>,
<Subject: [ForEx] 2010-10-25 - Foreign Exchange Rates Central Bank
Update Notice>, <Mime-Version: 1.0>, <Content-Type: text/plain>,
<Content-Transfer-Encoding: 7bit>>
#<Mail::Body:0x2ace72cd5878 @raw_source=“”, @epilogue=nil,
@charset=“US-ASCII”, @preamble=nil, @encoding=“7bit”, @parts=[],
@boundary=nil, @part_sort_order=[“text/plain”, “text/enriched”,
“text/html”]>
#<Mail::Body:0x2ace72cd5878 @raw_source=“”, @epilogue=nil,
@charset=“US-ASCII”, @preamble=nil, @encoding=“7bit”, @parts=[],
@boundary=nil, @part_sort_order=[“text/plain”, “text/enriched”,
“text/html”]>

Does anyone have any idea why the message body is not being generated
from the templates provided?

I generated the new mailer using the rails3 rails g mailer name idiom.
So, I assumed that the fact that a directory app/views/name indicated
where I should put the template files. However, removing this directory
has absolutely no effect on ActionMailer.

At the very least I would expect it to raise a missing template error.
But no, it behaves exactly as it has all along. It creates headers but
no body. So, where is it looking for the templates and why on earth
does it not fail if it cannot find them?

However, if I specify the template by calling the mail method with a do
block and providing a render call to a non-existent template then I do
get a template missing error raised.

What is going on here? The API clearly states that if the mail method
is called without a block then app/views are searched (presumably in a
directory with the same name as the mailer class) for any files having
the same stem name as the mailer method and ending in erb. So, why no
template error when the directory is missing?

I find that if I pass a block to the mail method and specify my template
therein then, and only then, is the email body generated. Is this the
expected behaviour? If so then the documentation is sadly misleading.