Link to home
Start Free TrialLog in
Avatar of Shawn
ShawnFlag for Canada

asked on

cfmail attachment error

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

Avatar of _agx_
_agx_
Flag of United States of America image

(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.
Avatar of Shawn

ASKER

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?
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.
Avatar of Shawn

ASKER

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

Avatar of Shawn

ASKER

B still says file not found. maybe it's linked to A as I can see the file.
ASKER CERTIFIED SOLUTION
Avatar of _agx_
_agx_
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Shawn

ASKER

omg the file name was wrong. works great as is. right in fron of my nose.
sorry about the wild goose chase.
lol. I did that yesterday.  I forgot the old rule of always check the silly stuff first .. because that's often the problem ;-)
Avatar of Shawn

ASKER

looks like it's back to the kiss principle. keep it simple stupid.

thx agx
> the kiss principle

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

ASKER

i hear ya and am guilty :)