On 2/15/06, Nicholas Couloute <njcjr@xxxxxxxxx> wrote: > How would u make a script that uploads files to ur server via email? 1. > user emails the server 2. if there is a audio file (amr) attached then > add it a folder! Are there any scripts that can do that? This will take some work but what you want to do is setup a email account that you designate as the "upload email". You will want to write a script to access this email box and download the content directory. Will probably cron this script. To really do this you need to understand how an email works, here is a quick and dirty tutorial you will DEFINITELY want to do some further reading on this. The headers define "metadata" (if you will) about the message. The body follows. In an email with attachments the header field 'Content-Type:' wil be 'multipart/mixed' and there will be a boundary field. The boundary field lists a string of text that will be used to separate the multiple parts of a message.You need to first verify that the message is a multipart message and if it is extract the boundary header. You can then parse through the message body splitting it about the boundaries. Have a look at this sample body: ------_=_NextPart_001_01C62DA8.DE513F67 Content-Type: multipart/alternative; boundary="----_=_NextPart_002_01C62DA8.DE513F67" ------_=_NextPart_002_01C62DA8.DE513F67 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable <snip> ------_=_NextPart_001_01C62DA8.DE513F67-- ------_=_NextPart_001_01C62DA8.DE513F67 Content-Type: image/jpeg; name="Lights-0001.jpg" Content-Transfer-Encoding: base64 Content-Description: Lights-0001.jpg Content-Disposition: attachment; filename="Lights-0001.jpg" /9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAAPAAA/+4ADkFkb2JlAGTAAAAAAf/b AIQABgQEBAUEBgUFBgkGBQYJCwgGBggLDAoKCwoKDBAMDAwMDAwQDA4PEA8ODBMTFBQTExwbGxsc <snip> ------_=_NextPart_002_01C62DA8.DE513F67-- Notice that each part of the message begins and ends with the boundary you extracted from the header. Once you have the contents of the attachment you will need to base64-decode it and save it to a file. All the necessary information to do this is contained within the body block. Make sure you also check the content type, size, and filename to make sure you are in fact getting the type of file you want. The rest is up to your imagination. I would check out http://pear.php.net/package/Net_POP3 and http://us2.php.net/imap. Let me know how it goes. -Mike -- ________________________________ Michael E. Crute http://mike.crute.org Linux takes junk and turns it into something useful. Windows takes something useful and turns it into junk. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php