ggurus Posted June 26, 2006 Share Posted June 26, 2006 Hello all,I am working on a script which has to check incoming email and save any attachments on the webserver along with some basic info, subject line, sent from etc.This does not have to work realtime, so an admin user for example goes to the script's page and clicks a button and the script will check the mailbox and save the attachments, also storing the other info in a mysql database. My question is how to extract the attachment from the email. I've been looking around on several forums, hotscripts, experts exchange and google of course, but i can't find anything that explains how to do this. I hope someone here can help me. I'm puzzled [img src=\"style_emoticons/[#EMO_DIR#]/huh.gif\" style=\"vertical-align:middle\" emoid=\":huh:\" border=\"0\" alt=\"huh.gif\" /]Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/12963-extract-attachments-from-email/ Share on other sites More sharing options...
redarrow Posted June 26, 2006 Share Posted June 26, 2006 Are you trying to get the atachment file name and put that inforamtion in the database.Then move that atachment to a folder and list the atachments on a pageand then get a link for the admin to be able to look at those atachments. Quote Link to comment https://forums.phpfreaks.com/topic/12963-extract-attachments-from-email/#findComment-49830 Share on other sites More sharing options...
ggurus Posted June 26, 2006 Author Share Posted June 26, 2006 [!--quoteo(post=388235:date=Jun 27 2006, 12:14 AM:name=redarrow)--][div class=\'quotetop\']QUOTE(redarrow @ Jun 27 2006, 12:14 AM) [snapback]388235[/snapback][/div][div class=\'quotemain\'][!--quotec--]Are you trying to get the atachment file name and put that inforamtion in the database.[/quote]No, I need the actual attachment itself to be saved. So it has to be taken of the mailserver and stored in a folder on the webserver. So say if someone emailed a Word document to script@mysite.com, then when the script is activated by the admin it would check for new email messages and see if there are any attachments. These attachments should then be saved under their original filename in a folder on the webserver. Quote Link to comment https://forums.phpfreaks.com/topic/12963-extract-attachments-from-email/#findComment-49849 Share on other sites More sharing options...
ggurus Posted June 27, 2006 Author Share Posted June 27, 2006 Anyone? Quote Link to comment https://forums.phpfreaks.com/topic/12963-extract-attachments-from-email/#findComment-49965 Share on other sites More sharing options...
redarrow Posted June 27, 2006 Share Posted June 27, 2006 when the admin reads an email is it from a php script?if so post the page that gets that information got an idear here lol......If the email is being read via a php script then we can add a button tothat script to update the database and then copy the file to another diretorythen let the admin read that email and attchment via another page.This is all guess work ok but an idear ok.link from the reading email script.[code]<a href="http://new_page.php?&cmd=$attachment_name">Save Email</a>[/code]$attachment_name will be the varable set by the email reading script.[code]<?phpif(!$_GET['cmd']=='$attachment_name') {$query="insert into database values('$attachment_name')";$result=mysql_query($query);$attachment_name;$newfile = 'attachment_folder/$attachment_name';if (!copy($attachment_name, $newfile)) { echo "failed to copy $file...\n";} }?> [/code]I hope this helps a little bit i now the code nearly there lol.... Quote Link to comment https://forums.phpfreaks.com/topic/12963-extract-attachments-from-email/#findComment-49968 Share on other sites More sharing options...
ggurus Posted June 27, 2006 Author Share Posted June 27, 2006 Thanks for the help so far, but this isn't exactly what i mean.The problem lies in that i do not now how to connect to the mailsever using php and then reading out emails from the email box. I would then need some function to read out the contents and find any attachments if they are present and save them to the server.In the code you put above the attachment is already stored on the server and you're just moving it.This system is meant to function as a very simple way for people to upate a knowledge base. People just send an email to kb@site.com When the admin goes online and visits the script he would have to click a "check for new email" button, similiar as the way outlook works. Then the script needs to check for mail and store attachments on the webserver.Now the attachments are saved and added to the db along with some simple info the admin can see a list of new attachments and get's the choice wheter or not to add them to the kb.All I need to know is how to connect to a mailserver using php and get the mail data from it, including any attachments. Quote Link to comment https://forums.phpfreaks.com/topic/12963-extract-attachments-from-email/#findComment-49978 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.