Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I posted this question already but it was too vague and so was closed so I hope this is a bit better.

We have a php based application which reads a csv report that is then added to a database and/or displayed in a graphic way for customers and ourselves. This works well but the issue we have is in getting the csv where we need it.

We receive reports automatically from a separate system which is not in our control. These arrive as attachement in emails sent regularly to a number of different email addresses. Currently we have software that will take the email from the email server (mostly google), extracts the csv file, renames it per our requirements and using ftp puts it in one of a number of locations depending on the address it arrives from. Though this works it runs on a local machine in our offices and needs to run constantly. What we need is to cut this out of the set up. I'm a website coder and not very strong when it comes to the server side so I don't know for sure but is there a way we can achieve the same results without the need for the software running on the machine?

  1. retrieves an email from the email server (it can go to any email address we need, we just currently use google for handiness)
  2. extracts the csv file
  3. renames the csv file
  4. adds it to a folder on our server

Thanks! If you think this is too vague or needs more info just ask please rather than just marking it wrong, I'm trying to be clear but without the jargon it can be difficult.

share|improve this question
    
Is php necessary...if not, have you looked at perl. IIRC, perl has some fairly nice tools for working with emails and attachments. –  jim_m_somewhere Dec 13 '12 at 18:42
    
It's still not clear where you want to move the retrieval software to... Could you include the functionality in your PHP app? –  Ward Dec 13 '12 at 18:49
1  
You can create this type of job in myriad of ways, either on a local workstation, a server, some cheapo VPS or whatever, and it doesn't really matter what system/language you use, as long as it has libraries/tools available to do what you want. Other than that, there is no real way to answer this because actually there is no real question in your post. Server Fault works best if you ask a specific question for a specific environment. E.g. something like "How do I download a mail from gmail and extract the attachment to a directory every 5 minutes on Linux". –  SvW Dec 13 '12 at 18:50
add comment

1 Answer

up vote 0 down vote accepted

You will need this software running somewhere, though given your requirements, it can run just about anywhere. You can write a program to handle all of that without the need for a web server - you'll basically retrieve the email via POP or IMAP, process it to pull out the attachment, then save the attachment to wherever it needs to be saved. PHP can do that, but so can Perl, Python, Ruby, or any number of others.

My method of implementation would be to run said program via cron every X minutes, sending an email alert to you if it noticed new messages but was unable to process them for some reason.

share|improve this answer
    
I put together a php version of the code to upload the info just before the other code runs. However, I don't know much about Cron so I will do some reading. Thanks –  Alan Doolan Dec 14 '12 at 8:59
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.