Hi, everyone. I’m getting a production server ready for a site I’m
working on, and I’ve been a bit stumped by a difference between the
development server (running under Webrick) and the production server
(running under lighttpd).
Here’s the scenario: I’m working on a variation of an e-commerce
system. When someone finalizes an order with our system, we not only
want to send them a confirmation e-mail message, but also a JPEG image
with a mailing label. The mailing label has been modified from an
original template using RMagick. So the bottom line is that I want to
send the user an e-mail message with two different parts – one with a
MIME type of text/html, and the other with a MIME type of image/jpeg.
The problem is that everything works perfectly under Webrick: I get the
text/html content, I get the image/jpeg content, and it looks just
swell. But when the same code (checked out from CVS, and double-checked
that they’re running identical code) runs under lighttpd, the text/html
content is completely missing. Looking at the source of the e-mail
shows that the text/html portion of the message is completely missing,
not just hiding or mangled. The image is always there, without any
problems whatsoever.
I’ve gone around and around with this, but can’t figure out what’s going
wrong. Can anyone suggest anything?
Here’s the mail-generation method that’s being invoked (from another,
public method) in my controller:
private
def generate_mailing_label_email
label = create_mailing_label(@order)
OrderMailer::deliver_mailing_label_message(@order, @person,
label)
end
And here is the method that’s defined in OrderMailer <
ActionMailer::Base:
def mailing_label_message(order, person, label)
@recipients = person.email_address
@subject = "Mailing label for MySite order ##{order.id}"
@from = "[email protected]"
@content_type = 'text/html'
@body[:order] = order
@body[:person] = person
attachment :content_type => 'image/jpeg', :body => label
end
mailing_label_message.rhtml is a simple bit of HTML, with one ERb call
in it – an invocation of link_to.
By the way, when I run the production server under WEBrick, I get the
same output as with lighttpd. So this seems to be a problem with the
production server. I don’t see any obvious permission issues, and I’m
certainly not getting any error logged to production.log (or anywhere
else I can see).
I’m guessing that I have either discovered a weird bug, that my system
is configured incorrectly, or that I’ve missed an obvious point about
sending e-mail with attachments. (In reverse order of probabilities, I
would say.) Whatever it is, please enlighten me!
Thanks,
Reuven