House of Fusion
Home of the ColdFusion Community
Hostmysite VPS Hosting

Search cf-talk

July 05, 2008

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
     1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31     

Subscribe Now
Fusion Authority Quarterly Update - ColdFusion 8 Special Edition

For ColdFusion hosting try HostMySite.com.
Search over 2,500 ColdFusion resources here  >>>      
Home /  Groups /  ColdFusion Talk (CF-Talk)

Deleting Attachments Immediately After CFMAIL

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Nathan Wells
10/25/2007 04:38 PM

Is there any way to safely delete files that were attached using a <cfmailparam> tag to an email that was generated with the <cfmail> tag?  If you delete the attached file too soon, then the file doesn't get attached to the email, at best, and at worst, the email fails altogether.   <cfmail to="me@here.com" to="you@there.com" subject="See Attachment">   <cfmailparam file="#theFullFilePath#">   See attached file, #GetFileFromPath(theFullFilePath)# </cfmail> <cffile action="delete" file="#theFullFilePath#"> I know for a fact that this worked just fine in CF 5, because the contents of the attached file would be included as a base64 string in the .mail file that was written to the spool.  In the MX versions of CF, only path of the attached file is put in the .mail file, meaning the attached file had to stick around until the .mail file in the spool could be processed. It seems like a significant feature digression, but I have found zero documentation on this from Adobe.  It is quite a hindrance if you are attaching (gasp) dynamically generated files to emails to create an entire separate process to manually clean up the files from the file system.   Does anybody know how attachments work in CF 8?  I haven't tried it yet, and I would be curious if it works the same as CF 7.   Has anyone heard of future plans by Adobe to allow attached files to be automatically deleted after the spool file has been processed.  Maybe something similar to the <cfcontent> tag?     <cfmailparam file="#theFullFilePath#" delete="yes"> And finally, has anyone ever tried to somehow force the contents of the file into the body of the email so it is indeed written to the spool file?

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Dan G. Switzer, II
10/25/2007 05:10 PM

Nathan, ----- Excess quoted text cut - see Original Post for more ----- Adobe did this to speed up mass e-mailings that all use a common set of attachments--which is common when doing bulk mailings. Obviously in this case there's considerably less disk space used and does speed things up. However, when you're trying to send dynamically generated content it's a real PITA. Here's a blog entry I wrote a while back which shows how the JavaMail API can be used directly to send SMTP without needing to write attachments to disk: http://blog.pengoworks.com/blogger/index.cfm?action=blog:584 There's also this blog entry over at Charlie Arehart's site which discusses some alternatives (see the comments): http://carehart.org/blog/client/index.cfm/2007/1/13/cfdocument_name_attribut e -Dan

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Nathan Wells
10/25/2007 06:22 PM

----- Excess quoted text cut - see Original Post for more ----- Dan, Thanks a lot for the references.  They both look very promising for our needs.   Our applications don't send that many emails, but I knew I wasn't the first one to run into problems like this.  You saved me some time searching in the dark.   Nathan

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Dan G. Switzer, II
10/26/2007 10:15 AM

Nathan, >Thanks a lot for the references.  They both look very promising for our >needs.  Our applications don't send that many emails, but I knew I wasn't >the first one to run into problems like this.  You saved me some time >searching in the dark. I went ahead and blogged an fully working example using the technique Jon Wolski pointed out on Charlie Arehart's blog: http://blog.pengoworks.com/blogger/index.cfm?action=blog:610 My example also shows using embedded images in an HTML message. -Dan

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Jochem van Dieten
10/26/2007 01:17 PM

Dan G. Switzer, II wrote: > I went ahead and blogged an fully working example using the technique Jon > Wolski pointed out on Charlie Arehart's blog: > > http://blog.pengoworks.com/blogger/index.cfm?action=blog:610 > > My example also shows using embedded images in an HTML message. Unfortunately your example produces messages that will not result in the desired rendering on conforming MUAs. Your attachments should be on the outermost MIME part, not nested somewhere in the middle. I.e, you have: multipart/alternative    multipart/mixed      HTML      txt      pdf      img (attachment)      img (inline)    application/unsupported It should be: multipart/mixed    multipart/alternative      multipart/related        HTML        img (inline)      txt    pdf    img (attachment) In Thunderbird I see a message with 4 attachments for your example. Jochem

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Ben Doom
10/25/2007 05:39 PM

Without having tried it, the first thing that springs to mind is to turn off mail spooling. In theory, attaching files should not be that much of a bother.  I think you have to add a header specifying filename, MIME header, etc., and you have to add the file as a base-64 encoded block at the end of the email.   Others (Jochem -- I'm looking at you!) could probably advise better about this. HTH --Ben Doom Nathan Wells wrote: ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Jochem van Dieten
10/26/2007 03:52 AM

Nathan Wells wrote: > Does anybody know how attachments work in CF 8? Same as in 7. > Has anyone heard of future plans by Adobe to allow attached files to be automatically deleted after the spool file has been processed.  Maybe something similar to the <cfcontent> tag?   >   <cfmailparam file="#theFullFilePath#" delete="yes"> I like that idea. Did you submit it? http://www.adobe.com/go/wish/ > And finally, has anyone ever tried to somehow force the contents of the file into the body of the email so it is indeed written to the spool file? I couldn't get it to work with the CF mail spool. It is pretty easy to use another mail spool or Javamail. Jochem

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Nathan Wells
04/04/2008 01:30 PM

It looks like this has been addressed in ColdFusion 8.0.1; from the release notes:  "The cfmail and cfmailparam tags now have a remove attribute that tells ColdFusion to remove any attachments after successful mail delivery." Complete release notes: http://www.adobe.com/support/documentation/en/coldfusion/801/cf801releasenotes.pdf ----- Excess quoted text cut - see Original Post for more ----- Jochem

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Daniel Roberts
10/27/2007 08:54 AM

How about keep a list of email attachments that need to be deleted. This could be in application or server scope. After an email is spooled up, add the attachement to the list or array. Have a scheduled task look through your spool folder every so often and if the attachment isn't in any of the spool file it is safe to delete.


<< Previous Thread Today's Threads Next Thread >>

Mailing Lists