Solved

CFPOP Attachments

Posted on 2004-10-01
9
509 Views
Last Modified: 2013-12-24
Hi all, I was wonder if someone can help me out with a problem.  I am setting up a standard CFPOP page to display a users email. I was wondering if there was any way to store the users email attachment that they receive and insert it into a SQL Database.  The final goal is to log all emails incoming and outgoing.  I figured I would use SQL2000 To store all email info this way everything can be easily searched thru by date or user and so on.  I am just lost on what to do with the attachment itself, should I store them in a database as Binary, not sure and some help or Ideas would greatly be appreciated.  I am also open to storing all attachments in a folder, I just need a way to link them to the Database Record.  Thanks for your time
0
Comment
Question by:joebox
  • 4
  • 3
  • 2
9 Comments
 
LVL 35

Expert Comment

by:mrichmon
ID: 12202984
If you stored then in a folder then just store the path to the folder in the database record.  You can use cffile's attributes to get the path to where the attachment was saved....
0
 
LVL 21

Expert Comment

by:pinaldave
ID: 12203156
Hi joebox,
1) it is good idea to store images into the folder. My company does that. We have images with their unique name in the database.

Sample database example:
1) nameoftheoriginalfile
2) modifiedfilename
3) datetimeinserted
4) pathstored

now we store all the files in the different folder for our usage. Well whatever the file is uploaded we rename those file with the applicationid and currenttimewithyr so it has now new uniquename.

We also save the current filename inthe database field. This is the way we have optimized our system. My company is one of the largest in USA to serve the images. That is really good as my company is not in porn business and we have so many hits.

Regards,
---Pinal
0
 

Author Comment

by:joebox
ID: 12222390
I like both answers and is how i propably would have done it.  I was just curious as to if there was any benefits of storing as binary in a database, but I guess not cause noone suggested it.  Doing it the way you guys say with cffile is there anyway to only accept certain attachment extensions.  For instance not to accept any attachments with a .exe file type???  I will probably split the points with you guys unless one of you can pull thru with this answer I will also add points to it.  thanks again for all your help and ideas....  Joe
0
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 
LVL 21

Expert Comment

by:pinaldave
ID: 12222430
sure, what you can do is specify what kind of mime type you want to upload. It is associated iwth your CFfile and you can specify what kind of file extention you want to upload.
<cffile
   action = "upload"
   fileField = "formfield"
   destination = "full_path_name"
   nameConflict = "behavior"
   accept = "mime_type/file_type"
   mode = "permission"
   attributes = "file_attribute_or_list">
http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/tags-p35.htm#wp3540091

Limits the MIME types to accept. Comma-delimited list. For example, to permit JPG and Microsoft Word file uploads:

accept = "image/jpg, application/msword"

The browser uses file extension to determine file type.


Regards,
---Pinal
0
 
LVL 35

Expert Comment

by:mrichmon
ID: 12222565
Watch out for the accept string PinalDave mentioned.  

It is buggy and for example
accept = "image/jpg" will not allow jpeg images sent from a mac.

Personally, I would save ALL attachements.

But when displaying since you know the name of the attachment - including filetype - do not allow the user to access any restricted extention types.  Instead display a message saying something like :

Filename : XXXXXXXXXXXX.exe is a restricted filetype.  Access Denied.

This way also saves you in the case that the director/manager comes and says "I need that file".  You can then recover it on a case-by-case basis, but you prevent the majority which are not legit, but most likely viruses.
0
 

Author Comment

by:joebox
ID: 12222890
mrichmon-
can you elabortate a little more, i think I like your approach better.  So what your saying is to save all attachents to a folder and when the user views thier mail, if that mail has an attachemnt with an .exe then just dont display it in thier mail message.
So once the file name is written to Database then I could do a plain <cfif mail.attachment contains "exe"> then dont display.  Is this kind of where you are going..... joe
0
 
LVL 35

Accepted Solution

by:
mrichmon earned 500 total points
ID: 12227561
Yes.

I assume that in your example mail is the query name?

If so then that is the exact kind of logic.

Something like:


<cfset restrictedfiles = "exe,scr,bat">

<cfloop index="attachment" list="attachmentlist">
   <cfloop index="extension" list="restrictedfiles">
       <cfif FindNoCase(extension, attachment)>
            Access is restricted to the attachment named: <cfoutput>#attachment#</cfoutput> because it is of a restricted filetype
        <cfelse>
            Display attachment or link to attachement
        </cfif>
    </cfloop>
</cfloop>
0
 

Author Comment

by:joebox
ID: 12235465
thanks so much for your help.....
0
 
LVL 35

Expert Comment

by:mrichmon
ID: 12238398
no problem :o)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows Server with multiple sites and SSL 14 67
question about access to website 2 79
AWS Advice on using WHM/cPanel 1 79
Stream live video from Raspberry Pi camera 22 191
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

840 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