Justin Reagor on 20 Jun 2008 11:59:53 -0700


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PhillyOnRails] ActiveMailer issue sending email with both attachment AND body content

  • From: Justin Reagor <justinwr@gmail.com>
  • To: talk@phillyonrails.org
  • Subject: Re: [PhillyOnRails] ActiveMailer issue sending email with both attachment AND body content
  • Date: Fri, 20 Jun 2008 14:59:29 -0400
  • Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:mime-version:in-reply-to :references:content-type:message-id:content-transfer-encoding:from :subject:date:to:x-mailer; bh=QVgniHdgvG0oXnyUprW1DkXriIBMOx2/cVjoV1WRw7w=; b=jcLtCGy60/aObdXQYj3DXvBVmAPyuCayI2QdK6CYUA+rzWUsl+TjeTlsdBdrE+r0rq /mcbjMtUN2FdyndFFj7d9FeHhjZRfuBA6m1owAf3qsA8nTukzXDtnT4Nncu8LsRie8ia /Ez0uJQ89KZpwZyG1s6hbsMr0pezdcRn0q8tw=
  • List-archive: <http://lists.phillyonrails.org/pipermail/talk>
  • Reply-to: talk@phillyonrails.org
  • Sender: talk-bounces@phillyonrails.org

I'm not sure about the attachments problem, but I just use .text.html.erb and .text.plain.erb and Rails handles sending out the two multipart encodings.

:: Justin Reagor
:: justinwr@gmail.com



On Jun 20, 2008, at 2:58 PM, Ryan Miller wrote:

No dice.
Andrew Libby wrote:
Try setting your content_type  to  "multipart/alternative"

Andy


Ryan Miller wrote:
Sure, thanks for your reply. You'll see in my model the two ways I've tried attaching the file. Both work, but both also remove my content
(view).

=========== controller ==============
class InfoController < ApplicationController
  protect_from_forgery :only => [:create, :delete, :update]
    def index
      Info.deliver_test_email(params, request.env)

      redirect_to request.env["HTTP_REFERER"]
  end
end
=========== end controller ===============

=========== model ===================
class Info < ActionMailer::Base

  def test_email(params, request)
    sent_on     Time.new
    subject     'Information request from website'
    recipients  params[:txtEmail]
from 'miller2300@comcast.net' content_type 'text/html'

    attachment :content_type => "image/jpeg",
       :body => File.read("/tmp/CGI.5798.6")
           body(:sent_on => sent_on,:first_name =>
params[:txtFirstName], :last_name => params [:txtLastName], :address =>
params[:txtEmail])
        #attachment "image/jpeg" do |a|
    #    a.filename="boris.jpg"
    #    a.body = File.read("/tmp/CGI.5654.4")
    #end
                end
end
============ end model ==============
============ view =============
<h3>Web form request at <%= @sent_on %></h3>

<p>From: <em><%= @first_name %> <%= @last_name %> (<%= @address % >)</em>
</p>
=========== end view ===========





-------- Forwarded Message --------
From: Andrew Libby <alibby@tangeis.com>
Reply-To: talk@phillyonrails.org
To: talk@phillyonrails.org
Subject: Re: [PhillyOnRails] ActiveMailer issue sending email with
both    attachment AND body content
Date: Thu, 19 Jun 2008 09:37:41 -0400

Mind posting your mailer code?

This might help us figure out what's going on.



Thanks.

Ryan Miller wrote:

I'm having some issues with a simple form mailer using ActiveMailer in rails
2.0.2.

I can send a plain old regular email just fine.
I can send an email with an attachment just fine.

But, when I try to send an email with body content AND an attachment, the email gets sent and delivered with the attachment, but the body content is completely empty. I've tried so many different things, but just can't get it to work. Anyone seen this before or suggest something to try? Many thanks in
advance.


// Ryan Miller
/*  Vive il sogno, via come il vento! */

_______________________________________________
To unsubscribe or change your settings, visit:
http://lists.phillyonrails.org/mailman/listinfo/talk



_______________________________________________
To unsubscribe or change your settings, visit:
http://lists.phillyonrails.org/mailman/listinfo/talk


_______________________________________________
To unsubscribe or change your settings, visit:
http://lists.phillyonrails.org/mailman/listinfo/talk

_______________________________________________
To unsubscribe or change your settings, visit:
http://lists.phillyonrails.org/mailman/listinfo/talk