I have an application in which users can send me feedback. When they do this, various data from their system is posted to a php file on my server. The php file then handles that data and sends me an email with that data via mail(). Right now, all of the data is just composed into an HTML email.
What I want to do is take some of the posted data, convert them to files, and add them as attachments to the email. I know how to add files as attachments with mail(). I just can't think of a way to create the files first. I thought of just using fopen() and fwrite(), but then what if two users are sending feedback at the same time, the files would get all messed up since they would have the same name for each user. I know php has a temp file function which generates a file with a random name, but then how would I reference that file to add to my mail headers for mail(). Also, the temp file function won't work because I want each file to have a specific name when sent to me.
Any ideas on how to accomplish this?