Solved

cfmail attachment error

Posted on 2011-09-22
11
372 Views
Last Modified: 2013-12-24
I have what should be a simple cfmail with an attachment and am getting the following error:

Security: The requested template has been denied access to d:\wwwroot\imailroom.ca\wwwroot\D:\wwwroot\imailroom.ca\imail_scans\TestClient\iEnvelopes\imr20110907_e_2B.gif.

Why is the code below adding "d:\wwwroot\imailroom.ca\wwwroot\" ?
<cfmail to="#firstname# #LastName# <#UserEmail#>" bcc="sfawcett@imailroom.ca"from="imailroom <siteadmin@imailroom.ca>"  subject="#esubject#" type="HTML" server="#application.webserver#">

new mail
<br><br>


<cfset testfile = "D:\wwwroot\imailroom.ca\imail_scans\TestClient\iEnvelopes\imr20110907_e_2B.gif">

this attachment works. test images and decide which should be used for envelopes and which should be used for pdf.
<cfmailparam file="#testfile#">


</cfmail>

Open in new window

0
Comment
Question by:Shawn
  • 6
  • 5
11 Comments
 
LVL 52

Expert Comment

by:_agx_
ID: 36582843
(no points..)

>> Why is the code below adding "d:\wwwroot\imailroom.ca\wwwroot\" ?

The permissions error sounds very familiar ...

Don't believe the error message 100%. Error messages are notoriously unreliable so it could just be a bunk message.  

Try running a few tests. Use hard coded paths temporarily. Just to be sure it's not a path problem.

a) try the cfmail with a hard coded path. If you still get the same error

b) verify the file exists.
<cfif fileExists("D:\wwwroot\imailroom.ca\imail_scans\TestClient\iEnvelopes\imr20110907_e_2B.gif")> file exists<cfelse>not found </cfif>
c) try and read the file
<cfset x = FileReadBinary("D:\wwwroot\imailroom.ca\imail_scans\TestClient\iEnvelopes\imr20110907_e_2B.gif")>

If B and C succeed it's probably a some weird permissions problem with the directories used by CF / cfmail.
0
 
LVL 1

Author Comment

by:Shawn
ID: 36582914
permissions sounds about right as the folder is outside of the web root (for security reasons).

If this is the case what sort of workaround would you suggest?
0
 
LVL 52

Expert Comment

by:_agx_
ID: 36582987
No, if the problem's what I think it is .. the issue is with whatever internal directories CF uses for mailing, not the directory containing your image. That's what the tests above should tell you. If only the mailing part A) fails that's probably the issue.

I remember there was a long thread about this .. if I could just find it.
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 1

Author Comment

by:Shawn
ID: 36583111
ok A failed and just to be sure I put the file in the web root and you're right there too. same issue.

B file not found...double checking code as this should work
getting to C

0
 
LVL 1

Author Comment

by:Shawn
ID: 36583129
B still says file not found. maybe it's linked to A as I can see the file.
0
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
ID: 36583245
>> B still says file not found. maybe it's linked to A as I can see the file.

If the file doesn't exist I'm surprised cfmail didn't tell you that.

Well usually (though not always) that means the path is just wrong ;-)  Don't depend on eyeballing it. Use a more conclusive test. Like running a DIR command on the full path or doing a cfdirectory listing.  ie Verify some other way the file exists and it is a permissions problem with that folder rather than cfmail. Make sense?

0
 
LVL 1

Author Comment

by:Shawn
ID: 36583647
omg the file name was wrong. works great as is. right in fron of my nose.
sorry about the wild goose chase.
0
 
LVL 52

Expert Comment

by:_agx_
ID: 36584004
lol. I did that yesterday.  I forgot the old rule of always check the silly stuff first .. because that's often the problem ;-)
0
 
LVL 1

Author Closing Comment

by:Shawn
ID: 36587818
looks like it's back to the kiss principle. keep it simple stupid.

thx agx
0
 
LVL 52

Expert Comment

by:_agx_
ID: 36588386
> the kiss principle

funny how despite knowing it's true, developers have to continually fight the almost instinctive urge to make things complicated ;-)
0
 
LVL 1

Author Comment

by:Shawn
ID: 36588597
i hear ya and am guilty :)
0

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Why is my Splunk Web URL not working? 2 84
Fixing Old Legacy Code 1 45
Handling onsession end function in Application.cfc 5 68
REGEX HELP 11 57
PROBLEM: How to add your own buttons to the bottom toolbar with paging info ( result count ). While creating a cfgrid, I ran into an issue where I wanted to embed my own custom buttons where the default ones ( insert / delete / etc… ) are for aes…
Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question