Skip to main content
Known Participant
September 22, 2009
Question

cfmail and attachments. A problem

  • September 22, 2009
  • 1 reply
  • 897 views

I am trying to use the cfmail option to email ads submitted to our website.  While the copy will come over just fine, whenever I try to add an image as an attachment, I get the following error:

Security: The requested template has been denied access to image.jpg

The code I am using to process the file and send the mail is as follows:

<cfif Len(attributes.adgraphic) GT 0>
        <cftry>
            <cffile action="upload"
                    nameconflict="makeunique"
                    filefield="adgraphic"
                    destination="/home/content/b/o/a/boatsandharbor/html/"
                    >
            <cfcatch>
                <cfset File.ServerFile = "">
            </cfcatch>
        </cftry>
       
    <cfelse>
        <cfset File.ServerFile = "">
    </cfif>

and:

<cfmail to="#Application.orderEmail#" from="automated@boats-and-harbors.com" subject="New Display Ad" mimeattach="#File.ServerFile#">
Name: #attributes.name#
Company:  #attributes.company#
Phone:  #attributes.phone#
Email: #attributes.email#
Address: #attributes.address#
City: #attributes.city#
State: #attributes.state#
Zipcode: #attributes.zip#
Fax: #attributes.fax#
Ad Size: #sizeOfAd#
Copy: #adCopy#

</cfmail>

Can anyone tell me what the problem is?  It's really getting me frustrated!

Jason

    This topic has been closed for replies.

    1 reply

    Inspiring
    September 22, 2009

    What happens if you try to use <cfmailparam> rather than MIMEATTACH?

    Before going any further, pls note that the FILE scope is deprecated, and should not be used (http://livedocs.adobe.com/coldfusion/8/htmldocs/Tags_f_10.html#3540091).  You should be using CFFILE, or better, specify a variable name with the RESULT attribute.

    Check what is in the SERVERFILE value. I suspect it's just the filename.  You're gonna want the path in there too so <cfmail> can find the file.

    --

    Adam

    Known Participant
    September 23, 2009

    mimeattach and ]]> both throw up the same error.

    Also, here is the rest of the error message. I think I forgot to include this in my original post...... The following is the internal exception message: access denied (java.io.FilePermission fishing.jpg read)

    Would you happen to know where I can find the java.io.FilePermission setting to see if I need to change it?

    Jason

    Date: Tue, 22 Sep 2009 17:02:45 -0600

    From: forums@adobe.com

    To: jew0312@live.com

    Subject: cfmail and attachments.  A problem

    What happens if you try to use <cfmailparam> rather than MIMEATTACH?

    Before going any further, pls note that the FILE scope is deprecated, and should not be used (http://livedocs.adobe.com/coldfusion/8/htmldocs/Tags_f_10.html#3540091). You should be using CFFILE, or better, specify a variable name with the RESULT attribute.

    Check what is in the SERVERFILE value. I suspect it's just the filename. You're gonna want the path in there too so <cfmail> can find the file.

    --

    Adam

    >

    Inspiring
    September 23, 2009

    Did you see my comment: "You're gonna want the path in there too so <cfmail> can find the file."  It looks to me like you're only passing the file NAME, not the full path to the file, possibly.

    --

    Adam